pub enum Modifier {
Shift = 1,
CapsLock = 2,
Ctrl = 4,
Alt = 8,
Logo = 64,
AltGr = 128,
}Expand description
Modifier keys with their corresponding bit values for Wayland protocol. These values match the modifier mask constants used in XKB and Wayland.
Modifiers can be combined by pressing multiple at once. The protocol uses bitwise OR to combine modifier states, allowing complex combinations like Ctrl+Shift+Alt.
§Examples
use wrtype::Modifier;
// Individual modifiers for common shortcuts
let ctrl = Modifier::Ctrl; // Ctrl+C, Ctrl+V
let shift = Modifier::Shift; // Shift+Tab, Shift+Arrow
let alt = Modifier::Alt; // Alt+Tab, Alt+F4
// Special keys
let super_key = Modifier::Logo; // Super/Windows key
let altgr = Modifier::AltGr; // AltGr for international chars
let caps = Modifier::CapsLock; // Toggle caps lock stateVariants§
Shift = 1
Shift key - bit 0 (value 1)
Used for capital letters, symbols, and navigation shortcuts.
§Examples
Shift + letter→ Capital letterShift + Tab→ Reverse tab navigationShift + Arrow→ Text selectionShift + F10→ Context menu
CapsLock = 2
Caps Lock - bit 1 (value 2) - handled as locked modifier
Toggle modifier that affects letter case. Unlike other modifiers, CapsLock toggles state rather than being held down.
§Examples
- Press once → Enable caps lock
- Press again → Disable caps lock
- Affects typing:
abecomesAwhen active
Ctrl = 4
Control key - bit 2 (value 4)
Primary modifier for application shortcuts and system commands.
§Examples
Ctrl + C→ CopyCtrl + V→ PasteCtrl + Z→ UndoCtrl + Shift + T→ Reopen closed tabCtrl + Alt + Delete→ System interrupt
Alt = 8
Alt key - bit 3 (value 8)
Alternative modifier for menu access and application shortcuts.
§Examples
Alt + Tab→ Application switcherAlt + F4→ Close windowAlt + Enter→ Properties/FullscreenAlt + letter→ Menu access (underlined letters)
Logo = 64
Logo/Super/Windows key - bit 6 (value 64)
System-level modifier typically used for desktop environment shortcuts. Also known as Super key on Linux or Windows key on Windows.
§Examples
Logo + L→ Lock screenLogo + D→ Show desktopLogo + R→ Run dialogLogo + number→ Launch taskbar applications
AltGr = 128
AltGr (right Alt) key - bit 7 (value 128)
Alternative Graphics modifier for typing international characters and symbols not available on the base keyboard layout.
§Examples
AltGr + e→ é (on many European layouts)AltGr + c→ ç (on many European layouts)AltGr + 4→ € (Euro symbol on many layouts)AltGr + 2→ @ (on some international layouts)
Implementations§
Source§impl Modifier
impl Modifier
Sourcepub fn from_name(name: &str) -> Option<Self>
pub fn from_name(name: &str) -> Option<Self>
Convert string modifier name to enum value.
Accepts both “logo” and “win” for the Windows/Super key. Case-insensitive matching for user convenience.
§Arguments
name- String name of the modifier (case-insensitive)
§Returns
Some(Modifier)- If the name matches a known modifierNone- If the name is not recognized
§Examples
use wrtype::Modifier;
// Standard modifier names (case-insensitive)
assert_eq!(Modifier::from_name("shift"), Some(Modifier::Shift));
assert_eq!(Modifier::from_name("CTRL"), Some(Modifier::Ctrl));
assert_eq!(Modifier::from_name("Alt"), Some(Modifier::Alt));
// Alternative names
assert_eq!(Modifier::from_name("win"), Some(Modifier::Logo));
assert_eq!(Modifier::from_name("logo"), Some(Modifier::Logo));
// Invalid names return None
assert_eq!(Modifier::from_name("super"), None);
assert_eq!(Modifier::from_name("command"), None);
assert_eq!(Modifier::from_name(""), None);§Accepted Names
"shift"→Modifier::Shift"capslock"→Modifier::CapsLock"ctrl"→Modifier::Ctrl"alt"→Modifier::Alt"logo"or"win"→Modifier::Logo"altgr"→Modifier::AltGr
Trait Implementations§
impl Copy for Modifier
impl StructuralPartialEq for Modifier
Auto Trait Implementations§
impl Freeze for Modifier
impl RefUnwindSafe for Modifier
impl Send for Modifier
impl Sync for Modifier
impl Unpin for Modifier
impl UnwindSafe for Modifier
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,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.