bitflags::bitflags! {
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Modifiers: u32 {
const ALT = 0x01;
const ALT_GRAPH = 0x2;
const CAPS_LOCK = 0x4;
const CONTROL = 0x8;
const FN = 0x10;
const FN_LOCK = 0x20;
const META = 0x40;
const NUM_LOCK = 0x80;
const SCROLL_LOCK = 0x100;
const SHIFT = 0x200;
const SYMBOL = 0x400;
const SYMBOL_LOCK = 0x800;
#[deprecated = "marked as legacy in the spec, use META instead"]
const HYPER = 0x1000;
#[deprecated = "marked as legacy in the spec, use META instead"]
const SUPER = 0x2000;
}
}
impl Modifiers {
pub fn shift(&self) -> bool {
self.contains(Modifiers::SHIFT)
}
pub fn ctrl(&self) -> bool {
self.contains(Modifiers::CONTROL)
}
pub fn alt(&self) -> bool {
self.contains(Modifiers::ALT)
}
pub fn meta(&self) -> bool {
self.contains(Modifiers::META)
}
}