Table of Contents

Class KeyBindings

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

Provides a collection of KeyBinding objects bound to a Key.

public class KeyBindings
Inheritance
KeyBindings
Inherited Members

Constructors

KeyBindings()

Initializes a new instance. This constructor is used when the KeyBindings are not bound to a View. This is used for Application.KeyBindings and unit tests.

KeyBindings(View)

Initializes a new instance bound to boundView.

Properties

Bindings

The collection of KeyBinding objects.

BoundView

The view that the KeyBindings are bound to.

Methods

Add(Key, params Command[])

Adds a new key combination that will trigger the commands in commands (if supported by the View - see GetSupportedCommands()).

This is a helper function for Add(Key, KeyBinding, View?). If used for a View ( BoundView is set), the scope will be set to Focused. Otherwise, it will be set to Application.

If the key is already bound to a different array of Commands it will be rebound commands.

Add(Key, KeyBinding, View?)

Adds a KeyBinding to the collection.

Add(Key, KeyBindingScope, params Command[])

Adds a new key combination that will trigger the commands in commands.

If the key is already bound to a different array of Commands it will be rebound commands.

Add(Key, KeyBindingScope, View?, params Command[])

Adds a new key combination that will trigger the commands in commands.

If the key is already bound to a different array of Commands it will be rebound commands.

Add(Key, View?, params Command[])

Adds a new key combination that will trigger the commands in commands (if supported by the View - see GetSupportedCommands()).

This is a helper function for Add(Key, KeyBinding, View?). If used for a View ( BoundView is set), the scope will be set to Focused. Otherwise, it will be set to Application.

If the key is already bound to a different array of Commands it will be rebound commands.

Clear()

Removes all KeyBinding objects from the collection.

Clear(params Command[])

Removes all key bindings that trigger the given command set. Views can have multiple different keys bound to the same command sets and this method will clear all of them.

Get(Key)

Gets the KeyBinding for the specified Key.

Get(Key, KeyBindingScope)

Gets the KeyBinding for the specified Key.

GetCommands(Key)

Gets the array of Commands bound to key if it exists.

GetKeyFromCommands(params Command[])

Gets the first Key bound to the set of commands specified by commands.

GetKeysFromCommands(params Command[])

Gets Keys bound to the set of commands specified by commands.

Remove(Key, View?)

Removes a KeyBinding from the collection.

ReplaceCommands(Key, params Command[])

Replaces the commands already bound to a key.

ReplaceKey(Key, Key)

Replaces a key combination already bound to a set of Commands.

TryGet(Key, out KeyBinding)

Gets the commands bound with the specified Key.

TryGet(Key, KeyBindingScope, out KeyBinding)

Gets the commands bound with the specified Key that are scoped to a particular scope.

See Also