1use win_hotkeys::HotkeyManager;
2use win_hotkeys::VKey;
3use windows::Win32::UI::Input::KeyboardAndMouse::VK_A;
4
5fn main() {
6 let mut hkm = HotkeyManager::<()>::new();
8
9 let vk_a1 = VKey::A;
10 let vk_a2 = VKey::from_keyname("a").unwrap();
11 let vk_a3 = VKey::from_vk_code(0x41);
12 let vk_a4 = VKey::from_vk_code(VK_A.0);
13
14 let vk_a5 = VKey::CustomKeyCode(0x41);
16
17 assert_eq!(vk_a1, vk_a2);
18 assert_eq!(vk_a1, vk_a3);
19 assert_eq!(vk_a1, vk_a4);
20 assert_eq!(vk_a1, vk_a5);
21
22 match vk_a5 {
25 VKey::A => {
26 println!("CustomKeyCode(0x41) matches against VKey::A");
28 }
29 _ => {
30 println!("You didn't use the match statement correctly!");
31 }
32 }
33
34 match vk_a5 {
36 _ if VKey::A == vk_a5 => {
37 println!("CustomKeyCode(0x41) matches against VKey::A");
39 }
40 _ => {}
41 }
42
43 hkm.register_hotkey(vk_a5, &[], || {
44 println!("You pressed A");
45 })
46 .unwrap();
47
48 hkm.event_loop();
49}