pub struct KeyModifiers(/* private fields */);Expand description
Keyboard modifier flags.
Implemented as a manual bitflag over u8 (SHIFT = 1, CONTROL = 2, ALT = 4,
SUPER = 8) rather than a bitflags-generated type, so
this stays a plain value type with no macro-generated API surface. Combine with |.
Implementations§
Source§impl KeyModifiers
impl KeyModifiers
Sourcepub const fn from_bits_truncate(bits: u8) -> Self
pub const fn from_bits_truncate(bits: u8) -> Self
Builds modifiers from a raw bitmask, silently ignoring any bits above SUPER (0b1111).
Bitmask layout: SHIFT = 1, CONTROL = 2, ALT = 4, SUPER = 8. This is the wire format
shared by backends that encode modifiers as a single byte (for example the WASM backend’s
JS/Rust boundary).
Sourcepub const fn from_parts(
shift: bool,
control: bool,
alt: bool,
super_: bool,
) -> Self
pub const fn from_parts( shift: bool, control: bool, alt: bool, super_: bool, ) -> Self
Builds modifiers from four independent flags, one per platform modifier key.
Naming all four as separate parameters (rather than taking a platform-specific modifiers type) makes the modifier set exhaustive by function signature: a backend that gains a fifth modifier fails to compile at every call site instead of silently dropping it.
Sourcepub const fn bits(self) -> u8
pub const fn bits(self) -> u8
Returns the raw bitmask, in the same layout from_bits_truncate
accepts. Only the low four bits are ever set.
Trait Implementations§
Source§impl BitAnd for KeyModifiers
impl BitAnd for KeyModifiers
Source§impl BitAndAssign for KeyModifiers
impl BitAndAssign for KeyModifiers
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl BitOr for KeyModifiers
impl BitOr for KeyModifiers
Source§impl BitOrAssign for KeyModifiers
impl BitOrAssign for KeyModifiers
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl Clone for KeyModifiers
impl Clone for KeyModifiers
Source§fn clone(&self) -> KeyModifiers
fn clone(&self) -> KeyModifiers
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more