onKey property

  1. @Deprecated('Use onKeyEvent instead. ' 'This feature was deprecated after v3.18.0-2.0.pre.')
FocusOnKeyCallback? onKey
getter/setter pair

Called if this focus node receives a key event while focused (i.e. when hasFocus returns true).

This property is deprecated and will be removed at a future date. Use onKeyEvent instead.

This is a legacy API based on RawKeyEvent and will be deprecated in the future. Prefer onKeyEvent instead.

Key Event Propagation

The FocusManager receives key events from HardwareKeyboard and will pass them to the focused nodes. It starts with the node with the primary focus, and will call the onKeyEvent callback for that node. If the callback returns KeyEventResult.ignored, indicating that it did not handle the event, the FocusManager will move to the parent of that node and call its onKeyEvent. If that onKeyEvent returns KeyEventResult.handled, then it will stop propagating the event. If it reaches the root FocusScopeNode, FocusManager.rootScope, the event is discarded.

Implementation

@Deprecated(
  'Use onKeyEvent instead. '
  'This feature was deprecated after v3.18.0-2.0.pre.',
)
FocusOnKeyCallback? onKey;