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 moreSource§impl Debug for KeyModifiers
impl Debug for KeyModifiers
Source§impl Default for KeyModifiers
impl Default for KeyModifiers
Source§fn default() -> KeyModifiers
fn default() -> KeyModifiers
Source§impl Hash for KeyModifiers
impl Hash for KeyModifiers
Source§impl Not for KeyModifiers
impl Not for KeyModifiers
Source§impl PartialEq for KeyModifiers
impl PartialEq for KeyModifiers
Source§fn eq(&self, other: &KeyModifiers) -> bool
fn eq(&self, other: &KeyModifiers) -> bool
self and other values to be equal, and is used by ==.impl Copy for KeyModifiers
impl Eq for KeyModifiers
impl StructuralPartialEq for KeyModifiers
Auto Trait Implementations§
impl Freeze for KeyModifiers
impl RefUnwindSafe for KeyModifiers
impl Send for KeyModifiers
impl Sync for KeyModifiers
impl Unpin for KeyModifiers
impl UnsafeUnpin for KeyModifiers
impl UnwindSafe for KeyModifiers
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<C> WithAlpha for Cwhere
C: Copy,
impl<C> WithAlpha for Cwhere
C: Copy,
§fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
self with alpha, storing alpha before the color in memory
(see [AlphaFirst]).§fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
self with alpha, storing alpha after the color in memory
(see [AlphaLast]).