use drmkit_input::{KeyEvent, Keyboard, KeymapNames};
const KEY_CAPSLOCK: u32 = 58;
fn main() {
unsafe { std::env::set_var("XKB_DEFAULT_OPTIONS", "ctrl:nocaps") };
let mut keyboard = Keyboard::from_names(&KeymapNames {
layout: "us".to_owned(),
..KeymapNames::default()
})
.expect("compile us");
let mut event = KeyEvent {
key: KEY_CAPSLOCK,
pressed: true,
..KeyEvent::default()
};
keyboard.process_key(&mut event);
assert!(
keyboard.modifiers().ctrl,
"XKB_DEFAULT_OPTIONS=ctrl:nocaps makes Caps Lock a Control key"
);
println!("xkb_default_options: Caps Lock is Control under ctrl:nocaps");
}