keyboard_types/
modifiers.rs1bitflags::bitflags! {
9 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
14 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
15 pub struct Modifiers: u32 {
16 const ALT = 0x01;
17 const ALT_GRAPH = 0x2;
18 const CAPS_LOCK = 0x4;
19 const CONTROL = 0x8;
20 const FN = 0x10;
21 const FN_LOCK = 0x20;
22 const META = 0x40;
23 const NUM_LOCK = 0x80;
24 const SCROLL_LOCK = 0x100;
25 const SHIFT = 0x200;
26 const SYMBOL = 0x400;
27 const SYMBOL_LOCK = 0x800;
28 const HYPER = 0x1000;
29 const SUPER = 0x2000;
30 }
31}
32
33impl Modifiers {
34 pub fn shift(&self) -> bool {
36 self.contains(Modifiers::SHIFT)
37 }
38
39 pub fn ctrl(&self) -> bool {
41 self.contains(Modifiers::CONTROL)
42 }
43
44 pub fn alt(&self) -> bool {
46 self.contains(Modifiers::ALT)
47 }
48
49 pub fn meta(&self) -> bool {
51 self.contains(Modifiers::META)
52 }
53}