KeyMsg class
Message sent when a key is pressed.
Contains the parsed Key with information about:
- The type of key (character, special key, function key)
- Modifier keys held (Ctrl, Alt, Shift)
Example
@override
(Model, Cmd?) update(Msg msg) {
return switch (msg) {
KeyMsg(key: Key(type: KeyType.up)) => (moveUp(), null),
KeyMsg(key: Key(type: KeyType.down)) => (moveDown(), null),
KeyMsg(key: Key(type: KeyType.runes, runes: [0x71])) => (this, Cmd.quit()), // 'q'
KeyMsg(key: Key(ctrl: true, runes: [0x63])) => (this, Cmd.quit()), // Ctrl+C
_ => (this, null),
};
}
- Inheritance
- Available extensions
Properties
Methods
-
matches(
List< KeyBinding> bindings) → bool -
Available on KeyMsg, provided by the KeyMsgMatchExtension extension
Returns true if this key message matches any of the given bindings. -
matchesSingle(
KeyBinding binding) → bool -
Available on KeyMsg, provided by the KeyMsgMatchExtension extension
Returns true if this key message matches the given binding. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override