KeyBinding class

A key binding that maps keys to actions with optional help text.

Key bindings are the foundation of TUI keyboard navigation. They allow you to define which keys trigger which actions, and provide help text for user documentation.

Example

final upBinding = KeyBinding(
  keys: ['up', 'k'],
  help: Help(key: '↑/k', desc: 'move up'),
);

final quitBinding = KeyBinding(
  keys: ['q', 'ctrl+c'],
  help: Help(key: 'q', desc: 'quit'),
);

Constructors

KeyBinding({List<String>? keys, Help? help, bool disabled = false})
Creates a new key binding.
KeyBinding.withHelp(List<String> keys, String keyText, String desc)
Creates a key binding with keys and help text.
factory
KeyBinding.withKeys(List<String> keys)
Creates a key binding with the given keys.
factory

Properties

enabled bool
Whether this binding is enabled.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
help Help
The help information for this binding.
no setter
keys List<String>
The keys that trigger this binding.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

disable() → void
Disables this binding.
enable() → void
Enables this binding.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setHelp(String key, String desc) → void
Sets the help text for this binding.
toString() String
A string representation of this object.
inherited
unbind() → void
Removes the keys and help from this binding, effectively nullifying it.

Operators

operator ==(Object other) bool
The equality operator.
inherited