zng::keyboard

Function on_key_input

source
pub fn on_key_input(
    child: impl UiNode,
    handler: impl WidgetHandler<KeyInputArgs>,
) -> impl UiNode
Expand description

P Event fired when a keyboard key is pressed or released and the widget is enabled.

§Route

The event is raised in the keyboard focused widget and then each parent up to the root. If propagation stop is requested the event is not notified further. If the widget is disabled or blocked the event is not notified.

This route is also called bubbling.

§Keys

Any key press/release generates a key input event, including keys codes that don’t map to any virtual key, see KeyInputArgs for more details.

For key combinations consider using a click_shortcut with a click handler.

§Underlying Event

This event property uses the KEY_INPUT_EVENT that is included in the default app.

§Preview

You can preview this event using on_pre_key_input. Otherwise the handler is only called after the widget content has a chance to stop propagation.

§Async

You can use async event handlers with this property.