Module zng::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());
    keyboard::on_key_input = hn!(|args: &keyboard::KeyInputArgs| {
        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 keyboard hardware events, received independent of what window or widget is focused.

Structs§

Enums§

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

Statics§

Traits§

Functions§