Skip to main content

Key

Enum Key 

Source
pub enum Key {
Show 111 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, Zero, One, Two, Three, Four, Five, Six, Seven, Eight, Nine, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DirectionUp, DirectionDown, DirectionLeft, DirectionRight, DirectionCenter, MoveHome, MoveEnd, PageUp, PageDown, Backspace, Delete, Enter, NumPadEnter, Tab, Spacebar, Escape, ShiftLeft, ShiftRight, CtrlLeft, CtrlRight, AltLeft, AltRight, MetaLeft, MetaRight, Minus, Equals, LeftBracket, RightBracket, Backslash, Semicolon, Apostrophe, Comma, Period, Slash, Grave, Back, Menu, Search, Info, Guide, Settings, ChannelUp, ChannelDown, ProgramRed, ProgramGreen, ProgramYellow, ProgramBlue, MediaPlay, MediaPause, MediaPlayPause, MediaStop, MediaNext, MediaPrevious, MediaRewind, MediaFastForward, MediaRecord, ButtonA, ButtonB, ButtonX, ButtonY, ButtonSelect, ButtonStart, Unknown,
}
Expand description

A key on a keyboard, remote control or game controller, named as in Jetpack Compose’s androidx.compose.ui.input.key.Key.

Letters and digits name the physical key, independent of the character the keyboard layout gives it.

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.

§

Zero

The 0 key on the main number row.

§

One

The 1 key on the main number row.

§

Two

The 2 key on the main number row.

§

Three

The 3 key on the main number row.

§

Four

The 4 key on the main number row.

§

Five

The 5 key on the main number row.

§

Six

The 6 key on the main number row.

§

Seven

The 7 key on the main number row.

§

Eight

The 8 key on the main number row.

§

Nine

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.

§

DirectionUp

The up arrow key, or up on a D-pad.

§

DirectionDown

The down arrow key, or down on a D-pad.

§

DirectionLeft

The left arrow key, or left on a D-pad.

§

DirectionRight

The right arrow key, or right on a D-pad.

§

DirectionCenter

The center button of a D-pad: OK or Select on a remote.

§

MoveHome

The Home key, which moves to the start of a line or list.

§

MoveEnd

The End key, which moves to the end of a line or list.

§

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.

§

NumPadEnter

The Enter key on the number pad.

§

Tab

The Tab key.

§

Spacebar

The space bar.

§

Escape

The Escape key.

§

ShiftLeft

The left Shift key.

§

ShiftRight

The right Shift key.

§

CtrlLeft

The left Control key.

§

CtrlRight

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.

§

Equals

The equals and plus key on US layouts.

§

LeftBracket

The left square bracket key on US layouts.

§

RightBracket

The right square bracket key on US layouts.

§

Backslash

The backslash key on US layouts.

§

Semicolon

The semicolon and colon key on US layouts.

§

Apostrophe

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.

§

Grave

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

§

Back

The Back key of a remote or of the Android system navigation.

§

Menu

The Menu key.

§

Search

The Search key of a remote.

§

Info

The Info key of a remote.

§

Guide

The Guide key of a remote, which opens the program guide.

§

Settings

The Settings key of a remote.

§

ChannelUp

The Channel Up key of a remote.

§

ChannelDown

The Channel Down key of a remote.

§

ProgramRed

The red program key of a remote.

§

ProgramGreen

The green program key of a remote.

§

ProgramYellow

The yellow program key of a remote.

§

ProgramBlue

The blue program key of a remote.

§

MediaPlay

The Play media key.

§

MediaPause

The Pause media key.

§

MediaPlayPause

The Play/Pause media key.

§

MediaStop

The Stop media key.

§

MediaNext

The Next track media key.

§

MediaPrevious

The Previous track media key.

§

MediaRewind

The Rewind media key.

§

MediaFastForward

The Fast Forward media key.

§

MediaRecord

The Record media key.

§

ButtonA

The A button of a game controller.

§

ButtonB

The B button of a game controller.

§

ButtonX

The X button of a game controller.

§

ButtonY

The Y button of a game controller.

§

ButtonSelect

The Select button of a game controller.

§

ButtonStart

The Start button of a game controller.

§

Unknown

Key not recognized or not mapped.

Implementations§

Source§

impl Key

Source

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

The key a W3C KeyboardEvent.code value names, such as "KeyA", "ArrowUp" or "MediaPlayPause". A code with no counterpart here is Key::Unknown.

Source

pub fn from_dom_event(code: &str, key: &str, key_code: u32) -> Key

The key a browser event names, as a TV browser reports a remote: by its code when it has one, else by its key value ("GoBack", "MediaPlayPause", "ChannelUp"), else by the keyCode Tizen (10009) and webOS (461) give the Back key.

Trait Implementations§

Source§

impl Clone for Key

Source§

fn clone(&self) -> Key

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 Key

Source§

impl Debug for Key

Source§

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

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

impl Eq for Key

Source§

impl Hash for Key

Source§

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

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 Key

Source§

fn eq(&self, other: &Key) -> 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 Key

Auto Trait Implementations§

§

impl Forget for Key

§

impl Freeze for Key

§

impl RefUnwindSafe for Key

§

impl Send for Key

§

impl Sync for Key

§

impl Unpin for Key

§

impl UnsafeUnpin for Key

§

impl UnwindSafe for Key

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

Source§

fn same_as(&self, other: &(dyn LayoutData + 'static)) -> bool

Whether other holds the same data, so a parent can keep its last measure.
Source§

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

The data as Any, to read it by its type.
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.