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.
- KeyInput
Args - Arguments for
KEY_INPUT_EVENT. - KeyRepeat
Config - System settings that define the key pressed repeat.
- Modifiers
Changed Args - Arguments for
MODIFIERS_CHANGED_EVENT. - Modifiers
State - 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
Keyhas entered. - Native
KeyCode - 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§
- Headless
AppKeyboard Ext - Extension trait that adds keyboard simulation methods to
HeadlessApp.
Functions§
- on_
disabled_ key_ input PEvent fired when a keyboard key is pressed or released and the widget is disabled.- on_
key_ down PEvent fired when a keyboard key is pressed and the widget is enabled.- on_
key_ input PEvent fired when a keyboard key is pressed or released and the widget is enabled.- on_
key_ up PEvent fired when a keyboard key is released and the widget is enabled.- on_
pre_ disabled_ key_ input PPreviewon_disabled_key_inputevent.- on_
pre_ key_ down PPreviewon_key_downevent.- on_
pre_ key_ input PPreviewon_key_inputevent.- on_
pre_ key_ up PPreviewon_key_upevent.