Skip to main content

KeyCode

Enum KeyCode 

Source
pub enum KeyCode {
Show 82 variants A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, Digit0, Digit1, Digit2, Digit3, Digit4, Digit5, Digit6, Digit7, Digit8, Digit9, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, ArrowUp, ArrowDown, ArrowLeft, ArrowRight, Home, End, PageUp, PageDown, Backspace, Delete, Enter, Tab, Space, Escape, ShiftLeft, ShiftRight, ControlLeft, ControlRight, AltLeft, AltRight, MetaLeft, MetaRight, Minus, Equal, BracketLeft, BracketRight, Backslash, Semicolon, Quote, Comma, Period, Slash, Backquote, Unknown,
}
Expand description

Physical key codes for keyboard input.

These represent physical keys on the keyboard, independent of the character they produce (which depends on keyboard layout).

Variants§

§

A

The A key.

§

B

The B key.

§

C

The C key.

§

D

The D key.

§

E

The E key.

§

F

The F key.

§

G

The G key.

§

H

The H key.

§

I

The I key.

§

J

The J key.

§

K

The K key.

§

L

The L key.

§

M

The M key.

§

N

The N key.

§

O

The O key.

§

P

The P key.

§

Q

The Q key.

§

R

The R key.

§

S

The S key.

§

T

The T key.

§

U

The U key.

§

V

The V key.

§

W

The W key.

§

X

The X key.

§

Y

The Y key.

§

Z

The Z key.

§

Digit0

The 0 key on the main number row.

§

Digit1

The 1 key on the main number row.

§

Digit2

The 2 key on the main number row.

§

Digit3

The 3 key on the main number row.

§

Digit4

The 4 key on the main number row.

§

Digit5

The 5 key on the main number row.

§

Digit6

The 6 key on the main number row.

§

Digit7

The 7 key on the main number row.

§

Digit8

The 8 key on the main number row.

§

Digit9

The 9 key on the main number row.

§

F1

The F1 function key.

§

F2

The F2 function key.

§

F3

The F3 function key.

§

F4

The F4 function key.

§

F5

The F5 function key.

§

F6

The F6 function key.

§

F7

The F7 function key.

§

F8

The F8 function key.

§

F9

The F9 function key.

§

F10

The F10 function key.

§

F11

The F11 function key.

§

F12

The F12 function key.

§

ArrowUp

The up arrow key.

§

ArrowDown

The down arrow key.

§

ArrowLeft

The left arrow key.

§

ArrowRight

The right arrow key.

§

Home

The Home key.

§

End

The End key.

§

PageUp

The Page Up key.

§

PageDown

The Page Down key.

§

Backspace

The Backspace key, which deletes backward.

§

Delete

The Delete key, which deletes forward.

§

Enter

The main Enter or Return key.

§

Tab

The Tab key.

§

Space

The space bar.

§

Escape

The Escape key.

§

ShiftLeft

The left Shift key.

§

ShiftRight

The right Shift key.

§

ControlLeft

The left Control key.

§

ControlRight

The right Control key.

§

AltLeft

The left Alt key, called Option on macOS.

§

AltRight

The right Alt key, called Option on macOS.

§

MetaLeft

The left Meta key: Command on macOS, the Windows key elsewhere.

§

MetaRight

The right Meta key: Command on macOS, the Windows key elsewhere.

§

Minus

The minus and underscore key on US layouts.

§

Equal

The equals and plus key on US layouts.

§

BracketLeft

The left square bracket key on US layouts.

§

BracketRight

The right square bracket key on US layouts.

§

Backslash

The backslash key on US layouts.

§

Semicolon

The semicolon and colon key on US layouts.

§

Quote

The apostrophe and quotation mark key on US layouts.

§

Comma

The comma key on US layouts.

§

Period

The period key on US layouts.

§

Slash

The forward slash key on US layouts.

§

Backquote

The grave accent and tilde key on US layouts, left of the 1 key.

§

Unknown

Key not recognized or not mapped.

Implementations§

Source§

impl KeyCode

Source

pub fn from_dom_code(code: &str) -> Self

The key a W3C KeyboardEvent.code value names, such as "KeyA", "ArrowUp" or "ShiftLeft"; "NumpadEnter" is KeyCode::Enter. A code with no counterpart here is KeyCode::Unknown.

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.