Modifier

Enum Modifier 

Source
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 state

Variants§

§

Shift = 1

Shift key - bit 0 (value 1)

Used for capital letters, symbols, and navigation shortcuts.

§Examples

  • Shift + letter → Capital letter
  • Shift + Tab → Reverse tab navigation
  • Shift + Arrow → Text selection
  • Shift + 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: a becomes A when active
§

Ctrl = 4

Control key - bit 2 (value 4)

Primary modifier for application shortcuts and system commands.

§Examples

  • Ctrl + C → Copy
  • Ctrl + V → Paste
  • Ctrl + Z → Undo
  • Ctrl + Shift + T → Reopen closed tab
  • Ctrl + Alt + Delete → System interrupt
§

Alt = 8

Alt key - bit 3 (value 8)

Alternative modifier for menu access and application shortcuts.

§Examples

  • Alt + Tab → Application switcher
  • Alt + F4 → Close window
  • Alt + Enter → Properties/Fullscreen
  • Alt + letter → Menu access (underlined letters)

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 screen
  • Logo + D → Show desktop
  • Logo + R → Run dialog
  • Logo + 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

Source

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 modifier
  • None - 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§

Source§

impl Clone for Modifier

Source§

fn clone(&self) -> Modifier

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Modifier

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Modifier

Source§

fn eq(&self, other: &Modifier) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Modifier

Source§

impl StructuralPartialEq for Modifier

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.