Skip to main content

VirtualKey

Enum VirtualKey 

Source
#[repr(u16)]
pub enum VirtualKey {
Show 113 variants Backspace = 8, Tab = 9, Return = 13, Pause = 19, CapsLock = 20, Esc = 27, Space = 32, PgUp = 33, PgDown = 34, End = 35, Home = 36, LeftArrow = 37, UpArrow = 38, RightArrow = 39, DownArrow = 40, PrintScreen = 44, Insert = 45, Delete = 46, Number0 = 48, Number1 = 49, Number2 = 50, Number3 = 51, Number4 = 52, Number5 = 53, Number6 = 54, Number7 = 55, Number8 = 56, Number9 = 57, A = 65, B = 66, C = 67, D = 68, E = 69, F = 70, G = 71, H = 72, I = 73, J = 74, K = 75, L = 76, M = 77, N = 78, O = 79, P = 80, Q = 81, R = 82, S = 83, T = 84, U = 85, V = 86, W = 87, X = 88, Y = 89, Z = 90, LeftWindows = 91, RightWindows = 92, Menu = 93, Numpad0 = 96, Numpad1 = 97, Numpad2 = 98, Numpad3 = 99, Numpad4 = 100, Numpad5 = 101, Numpad6 = 102, Numpad7 = 103, Numpad8 = 104, Numpad9 = 105, Multiply = 106, Add = 107, Subtract = 109, Decimal = 110, Divide = 111, F1 = 112, F2 = 113, F3 = 114, F4 = 115, F5 = 116, F6 = 117, F7 = 118, F8 = 119, F9 = 120, F10 = 121, F11 = 122, F12 = 123, NumLock = 144, ScrollLock = 145, LeftShift = 160, RightShift = 161, LeftCtrl = 162, RightCtrl = 163, LeftAlt = 164, RightAlt = 165, VolumeMute = 173, VolumeDown = 174, VolumeUp = 175, MediaNextTrack = 176, MediaPrevTrack = 177, MediaStop = 178, MediaPlayPause = 179, Oem1 = 186, OemPlus = 187, OemComma = 188, OemMinus = 189, OemPeriod = 190, Oem2 = 191, Oem3 = 192, Oem4 = 219, Oem5 = 220, Oem6 = 221, Oem7 = 222, Oem8 = 223, Oem102 = 226, Other(u16),
}
Available on crate feature input only.
Expand description

Key with a virtual key code, usable for hotkeys.

Microsoft docs for virtual key codes

Variants§

§

Backspace = 8

§

Tab = 9

§

Return = 13

§

Pause = 19

§

CapsLock = 20

§

Esc = 27

§

Space = 32

§

PgUp = 33

§

PgDown = 34

§

End = 35

§

Home = 36

§

LeftArrow = 37

§

UpArrow = 38

§

RightArrow = 39

§

DownArrow = 40

§

PrintScreen = 44

§

Insert = 45

§

Delete = 46

§

Number0 = 48

§

Number1 = 49

§

Number2 = 50

§

Number3 = 51

§

Number4 = 52

§

Number5 = 53

§

Number6 = 54

§

Number7 = 55

§

Number8 = 56

§

Number9 = 57

§

A = 65

§

B = 66

§

C = 67

§

D = 68

§

E = 69

§

F = 70

§

G = 71

§

H = 72

§

I = 73

§

J = 74

§

K = 75

§

L = 76

§

M = 77

§

N = 78

§

O = 79

§

P = 80

§

Q = 81

§

R = 82

§

S = 83

§

T = 84

§

U = 85

§

V = 86

§

W = 87

§

X = 88

§

Y = 89

§

Z = 90

§

LeftWindows = 91

§

RightWindows = 92

§

Menu = 93

§

Numpad0 = 96

§

Numpad1 = 97

§

Numpad2 = 98

§

Numpad3 = 99

§

Numpad4 = 100

§

Numpad5 = 101

§

Numpad6 = 102

§

Numpad7 = 103

§

Numpad8 = 104

§

Numpad9 = 105

§

Multiply = 106

§

Add = 107

§

Subtract = 109

§

Decimal = 110

§

Divide = 111

§

F1 = 112

§

F2 = 113

§

F3 = 114

§

F4 = 115

§

F5 = 116

§

F6 = 117

§

F7 = 118

§

F8 = 119

§

F9 = 120

§

F10 = 121

§

F11 = 122

§

F12 = 123

§

NumLock = 144

§

ScrollLock = 145

§

LeftShift = 160

§

RightShift = 161

§

LeftCtrl = 162

§

RightCtrl = 163

§

LeftAlt = 164

§

RightAlt = 165

§

VolumeMute = 173

§

VolumeDown = 174

§

VolumeUp = 175

§

MediaNextTrack = 176

§

MediaPrevTrack = 177

§

MediaStop = 178

§

MediaPlayPause = 179

§

Oem1 = 186

Used for miscellaneous characters; it can vary by keyboard.

  • For the US standard keyboard, the ‘;:’ key
  • For the German keyboard, the ‘ü’ key
§

OemPlus = 187

For any country/region, the ‘+’ key

§

OemComma = 188

For any country/region, the ‘,’ key

§

OemMinus = 189

For any country/region, the ‘-’ key

§

OemPeriod = 190

For any country/region, the ‘.’ key

§

Oem2 = 191

Used for miscellaneous characters; it can vary by keyboard.

  • For the US standard keyboard, the ‘/?’ key
  • For the German keyboard, the ‘#’’ key
§

Oem3 = 192

Used for miscellaneous characters; it can vary by keyboard.

  • For the US standard keyboard, the ‘`~’ key
  • For the German keyboard, the ‘ö’ key
§

Oem4 = 219

Used for miscellaneous characters; it can vary by keyboard.

  • For the US standard keyboard, the ‘[{’ key
  • For the German keyboard, the ‘ß?’ key
§

Oem5 = 220

Used for miscellaneous characters; it can vary by keyboard.

  • For the US standard keyboard, the ‘|’ key besides ‘Enter’
  • For the German keyboard, the ‘^°’ key
§

Oem6 = 221

Used for miscellaneous characters; it can vary by keyboard.

  • For the US standard keyboard, the ‘]}’ key
  • For the German keyboard, the ‘´`’ key
§

Oem7 = 222

Used for miscellaneous characters; it can vary by keyboard.

  • For the US standard keyboard, the ‘single-quote/double-quote’ key
  • For the German keyboard, the ‘ä’ key
§

Oem8 = 223

§

Oem102 = 226

Used for miscellaneous characters; it can vary by keyboard.

  • For the US standard keyboard, the ‘|’ key besides the ‘z’ key
  • For the German keyboard, the ‘<>’ key
§

Other(u16)

Other virtual key code.

Implementations§

Source§

impl VirtualKey

Source

pub fn is_lock_toggled(self) -> bool

Returns true if the key has lock functionality (e.g. Caps Lock) and the lock is toggled.

Trait Implementations§

Source§

impl Add<VirtualKey> for Modifier

Source§

type Output = KeyCombination

The resulting type after applying the + operator.
Source§

fn add(self, rhs: VirtualKey) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<VirtualKey> for ModifierCombination

Source§

type Output = KeyCombination

The resulting type after applying the + operator.
Source§

fn add(self, rhs: VirtualKey) -> Self::Output

Performs the + operation. Read more
Source§

impl Clone for VirtualKey

Source§

fn clone(&self) -> VirtualKey

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for VirtualKey

Source§

impl Debug for VirtualKey

Source§

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

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

impl Eq for VirtualKey

Source§

impl From<VirtualKey> for KeyCombination

Source§

fn from(key: VirtualKey) -> Self

Converts to this type from the input type.
Source§

impl From<VirtualKey> for i32

Source§

fn from(value: VirtualKey) -> Self

Converts to this type from the input type.
Source§

impl From<VirtualKey> for u16

Source§

fn from(enum_value: VirtualKey) -> Self

Converts to this type from the input type.
Source§

impl From<VirtualKey> for u32

Source§

fn from(value: VirtualKey) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for VirtualKey

Source§

fn from(number: u16) -> Self

Converts to this type from the input type.
Source§

impl FromPrimitive for VirtualKey

Source§

type Primitive = u16

Source§

fn from_primitive(number: Self::Primitive) -> Self

Source§

impl GenericKey for VirtualKey

Source§

fn is_pressed(self) -> Result<bool>

Source§

fn press(self) -> Result<()>

Globally sends a ‘press’ event (without a corresponding ‘release’). Read more
Source§

fn release(self) -> Result<()>

Globally sends a ‘release’ event.
Source§

fn send_combination(keys: &[Self]) -> Result<()>

Globally sends a key (or mouse button) combination as if the user had performed it. Read more
Source§

impl Hash for VirtualKey

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for VirtualKey

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for VirtualKey

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