Skip to main content

KeyCode

Enum KeyCode 

Source
pub enum KeyCode {
Show 127 variants KeyA, KeyB, KeyC, KeyD, KeyE, KeyF, KeyG, KeyH, KeyI, KeyJ, KeyK, KeyL, KeyM, KeyN, KeyO, KeyP, KeyQ, KeyR, KeyS, KeyT, KeyU, KeyV, KeyW, KeyX, KeyY, KeyZ, Digit0, Digit1, Digit2, Digit3, Digit4, Digit5, Digit6, Digit7, Digit8, Digit9, Backquote, Minus, Equal, BracketLeft, BracketRight, Backslash, Semicolon, Quote, Comma, Period, Slash, IntlBackslash, IntlRo, IntlYen, Escape, Tab, CapsLock, Backspace, Enter, Space, ShiftLeft, ShiftRight, ControlLeft, ControlRight, AltLeft, AltRight, MetaLeft, MetaRight, ContextMenu, Insert, Delete, Home, End, PageUp, PageDown, ArrowUp, ArrowDown, ArrowLeft, ArrowRight, PrintScreen, ScrollLock, Pause, NumLock, Numpad0, Numpad1, Numpad2, Numpad3, Numpad4, Numpad5, Numpad6, Numpad7, Numpad8, Numpad9, NumpadDivide, NumpadMultiply, NumpadSubtract, NumpadAdd, NumpadEnter, NumpadDecimal, NumpadEqual, NumpadComma, KanaMode, Lang1, Lang2, Convert, NonConvert, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, Unidentified,
}
Expand description

A key by where it is on the keyboard, whatever the layout says it types: the W3C UI Events code names (KeyA is the key right of Caps Lock, also on an AZERTY keyboard).

Variants§

§

KeyA

§

KeyB

§

KeyC

§

KeyD

§

KeyE

§

KeyF

§

KeyG

§

KeyH

§

KeyI

§

KeyJ

§

KeyK

§

KeyL

§

KeyM

§

KeyN

§

KeyO

§

KeyP

§

KeyQ

§

KeyR

§

KeyS

§

KeyT

§

KeyU

§

KeyV

§

KeyW

§

KeyX

§

KeyY

§

KeyZ

§

Digit0

§

Digit1

§

Digit2

§

Digit3

§

Digit4

§

Digit5

§

Digit6

§

Digit7

§

Digit8

§

Digit9

§

Backquote

§

Minus

§

Equal

§

BracketLeft

§

BracketRight

§

Backslash

§

Semicolon

§

Quote

§

Comma

§

Period

§

Slash

§

IntlBackslash

§

IntlRo

§

IntlYen

§

Escape

§

Tab

§

CapsLock

§

Backspace

§

Enter

§

Space

§

ShiftLeft

§

ShiftRight

§

ControlLeft

§

ControlRight

§

AltLeft

§

AltRight

§

MetaLeft

§

MetaRight

§

ContextMenu

§

Insert

§

Delete

§

Home

§

End

§

PageUp

§

PageDown

§

ArrowUp

§

ArrowDown

§

ArrowLeft

§

ArrowRight

§

PrintScreen

§

ScrollLock

§

Pause

§

NumLock

§

Numpad0

§

Numpad1

§

Numpad2

§

Numpad3

§

Numpad4

§

Numpad5

§

Numpad6

§

Numpad7

§

Numpad8

§

Numpad9

§

NumpadDivide

§

NumpadMultiply

§

NumpadSubtract

§

NumpadAdd

§

NumpadEnter

§

NumpadDecimal

§

NumpadEqual

§

NumpadComma

§

KanaMode

§

Lang1

§

Lang2

§

Convert

§

NonConvert

§

F1

§

F2

§

F3

§

F4

§

F5

§

F6

§

F7

§

F8

§

F9

§

F10

§

F11

§

F12

§

F13

§

F14

§

F15

§

F16

§

F17

§

F18

§

F19

§

F20

§

F21

§

F22

§

F23

§

F24

§

Unidentified

A key without a name here: see the event’s native code.

Implementations§

Source§

impl KeyCode

Source

pub fn name(self) -> &'static str

Its W3C code name.

Source§

impl KeyCode

Source

pub fn from_evdev(code: u32) -> KeyCode

The key a Linux evdev code stands for (GTK’s and Qt’s hardware key codes, on X11 and Wayland, are 8 more).

Source

pub fn from_keysym(keysym: u32) -> Option<KeyCode>

The key an XKB keysym names, for the keys that type no character (modifiers, Caps Lock, Escape, arrows, function keys); None for the others. A keymap’s options move these (ctrl:swapcaps, caps:escape) above the evdev code, as macOS and Windows remap below theirs, so they’re read from the keysym the key types. Meta is left out: it’s Shift+Alt’s keysym on most layouts.

Source

pub fn from_mac(code: u16) -> KeyCode

The key a macOS virtual key code stands for.

Source

pub fn from_windows_scancode(code: u32) -> KeyCode

The key a Windows scan code stands for: set 1, 0xE0 in the high byte for extended keys (as WM_KEYDOWN flags them).

Source

pub fn from_us_char(c: char) -> KeyCode

The key that types this character on a US keyboard, unshifted: what tests type.

Source

pub fn us_char(self) -> Option<char>

The character this key types on a US keyboard, unshifted: what tests and synthesized keys report as unmodified. None for a key that types none.

Source

pub fn from_key(key: Key) -> KeyCode

The key that types or is key on a US keyboard: what tests press.

Trait Implementations§

Source§

impl Clone for KeyCode

Source§

fn clone(&self) -> Self

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 KeyCode

Source§

impl Debug for KeyCode

Source§

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

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

impl Eq for KeyCode

Source§

impl Hash for KeyCode

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 KeyCode

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for KeyCode

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> AnyEq for T
where T: Any + PartialEq,

Source§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

Source§

fn as_any(&self) -> &(dyn Any + 'static)

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.