zng::keyboard

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::prelude::*;

APP.defaults().enable_device_events().run_window(async {
    keyboard::raw_device_events::KEY_EVENT.on_pre_event(app_hn!(|args: &keyboard::raw_device_events::KeyArgs, _| {
        if args.state == keyboard::KeyState::Pressed {
            println!("key pressed {:?}", args.key_code);
        }
    })).perm();

    Window!()
});

Structs§

Statics§