Module raw_device_events

Module raw_device_events 

Source
Expand description

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

You must enable device events in the app to receive this events.

use zng::app::raw_device_events::InputDeviceCapability;
use zng::prelude::*;

APP.defaults().run_window(async {
    APP.device_events_filter().modify(|f| f.input |= InputDeviceCapability::KEY);

    keyboard::raw_device_events::KEY_EVENT
        .on_pre_event(hn!(|args| {
            if args.state == keyboard::KeyState::Pressed {
                println!("key pressed {:?}", args.key_code);
            }
        }))
        .perm();

    Window!()
});

Structs§

KeyArgs
Arguments for the KEY_EVENT.

Statics§

KEY_EVENT
Keyboard device key press.