Module keyboard

Module keyboard 

Source
Expand description

Keyboard service, properties, events and other types.

The example below defines a window that shows the pressed keys and prints the key state changes.

use zng::prelude::*;

Window! {
    child = Text!(keyboard::KEYBOARD.keys().map_debug(false));
    keyboard::on_key_input = hn!(|args| {
        println!("key {:?} {:?}", args.key, args.state);
    });
}

Keyboard events are send to the focused widget, if there is no focused widget no event is send. You can subscribe directly to the KEY_INPUT_EVENT to monitor all keyboard events for any focused widget.

§Full API

See zng_ext_input::keyboard and zng_wgt_input::keyboard for the full keyboard API. See zng_app::view_process::raw_events for raw keyboard events that are processed to generate the key input event.

Modules§

raw_device_events
Raw keyboard hardware events, received independent of what window or widget is focused.

Structs§

KEYBOARD
Keyboard service.
KeyInputArgs
Arguments for KEY_INPUT_EVENT.
KeyRepeatConfig
System settings that define the key pressed repeat.
ModifiersChangedArgs
Arguments for MODIFIERS_CHANGED_EVENT.
ModifiersState
Represents the current state of the keyboard modifiers.

Enums§

Key
Key represents the meaning of a key press.
KeyCode
Represents the location of a physical key.
KeyLocation
The location of the key on the keyboard.
KeyState
State a Key has entered.
NativeKeyCode
Contains the platform-native physical key identifier

Statics§

KEY_INPUT_EVENT
Key pressed, repeat pressed or released event.
MODIFIERS_CHANGED_EVENT
Modifiers key state changed event.

Traits§

HeadlessAppKeyboardExt
Extension trait that adds keyboard simulation methods to HeadlessApp.

Functions§

on_disabled_key_input
P Event fired when a keyboard key is pressed or released and the widget is disabled.
on_key_down
P Event fired when a keyboard key is pressed and the widget is enabled.
on_key_input
P Event fired when a keyboard key is pressed or released and the widget is enabled.
on_key_up
P Event fired when a keyboard key is released and the widget is enabled.
on_pre_disabled_key_input
P Preview on_disabled_key_input event.
on_pre_key_down
P Preview on_key_down event.
on_pre_key_input
P Preview on_key_input event.
on_pre_key_up
P Preview on_key_up event.