RawKeyboard class

An interface for listening to raw key events.

This class is deprecated and will be removed at a future date. The HardwareKeyboard class is its replacement.

Raw key events pass through as much information as possible from the underlying platform's key events, which makes them provide a high level of fidelity but a low level of portability.

A RawKeyboard is useful for listening to raw key events and hardware buttons that are represented as keys. Typically used by games and other apps that use keyboards for purposes other than text entry.

These key events are typically only key events generated by a hardware keyboard, and not those from software keyboards or input method editors.

Compared to HardwareKeyboard

Behavior-wise, RawKeyboard provides a less unified, less regular event model than HardwareKeyboard. For example:

  • Down events might not be matched with an up event, and vice versa (the set of pressed keys is silently updated).
  • The logical key of the down event might not be the same as that of the up event.
  • Down events and repeat events are not easily distinguishable (must be tracked manually).
  • Lock modes (such as CapsLock) only have their "enabled" state recorded. There's no way to acquire their pressing state.

See also:

Annotations
  • @Deprecated('Use HardwareKeyboard instead. ' 'This feature was deprecated after v3.18.0-2.0.pre.')

Properties

hashCode int
The hash code for this object.
no setterinherited
keyEventHandler RawKeyEventHandler?
A handler for raw hardware keyboard events that will stop propagation if the handler returns true.
getter/setter pair
keysPressed Set<LogicalKeyboardKey>
Returns the set of keys currently pressed.
no setter
physicalKeysPressed Set<PhysicalKeyboardKey>
Returns the set of physical keys currently pressed.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addListener(ValueChanged<RawKeyEvent> listener) → void
Register a listener that is called every time the user presses or releases a hardware keyboard key.
clearKeysPressed() → void
Clears the list of keys returned from keysPressed.
handleRawKeyEvent(RawKeyEvent event) bool
Process a new RawKeyEvent by recording the state changes and dispatching to listeners.
lookUpLayout(PhysicalKeyboardKey physicalKey) LogicalKeyboardKey?
Returns the logical key that corresponds to the given pressed physical key.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeListener(ValueChanged<RawKeyEvent> listener) → void
Stop calling the given listener every time the user presses or releases a hardware keyboard key.
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

instance RawKeyboard
The shared instance of RawKeyboard.
final