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 #[deprecated = "marked as legacy in the spec, use META instead"]
29 const HYPER = 0x1000;
30 #[deprecated = "marked as legacy in the spec, use META instead"]
31 const SUPER = 0x2000;
32 }
33}
34
35impl Modifiers {
36 pub fn shift(&self) -> bool {
38 self.contains(Modifiers::SHIFT)
39 }
40
41 pub fn ctrl(&self) -> bool {
43 self.contains(Modifiers::CONTROL)
44 }
45
46 pub fn alt(&self) -> bool {
48 self.contains(Modifiers::ALT)
49 }
50
51 pub fn meta(&self) -> bool {
53 self.contains(Modifiers::META)
54 }
55}