Key

Enum Key 

Source
pub enum Key {
Show 107 variants Escape, Enter, Tab, Backspace, Space, Insert, Delete, Home, End, PageUp, PageDown, ArrowLeft, ArrowUp, ArrowRight, ArrowDown, 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, D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, Num0, Num1, Num2, Num3, Num4, Num5, Num6, Num7, Num8, Num9, NumMultiply, NumAdd, NumSubtract, NumDivide, NumDecimal, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, CapsLock, NumLock, ScrollLock, Pause, Apps, Sleep, MediaPlayPause, MediaStop, MediaNext, MediaPrevious, VolumeUp, VolumeDown, VolumeMute, BrowserBack, BrowserForward, BrowserRefresh, BrowserHome,
}
Expand description

Keyboard key enumeration

Variants§

§

Escape

Escape key

§

Enter

Enter/Return key

§

Tab

Tab key

§

Backspace

Backspace key

§

Space

Space bar

§

Insert

Insert key

§

Delete

Delete key

§

Home

Home key

§

End

End key

§

PageUp

Page Up key

§

PageDown

Page Down key

§

ArrowLeft

Left arrow key

§

ArrowUp

Up arrow key

§

ArrowRight

Right arrow key

§

ArrowDown

Down arrow key

§

A

A key

§

B

B key

§

C

C key

§

D

D key

§

E

E key

§

F

F key

§

G

G key

§

H

H key

§

I

I key

§

J

J key

§

K

K key

§

L

L key

§

M

M key

§

N

N key

§

O

O key

§

P

P key

§

Q

Q key

§

R

R key

§

S

S key

§

T

T key

§

U

U key

§

V

V key

§

W

W key

§

X

X key

§

Y

Y key

§

Z

Z key

§

D0

0 key

§

D1

1 key

§

D2

2 key

§

D3

3 key

§

D4

4 key

§

D5

5 key

§

D6

6 key

§

D7

7 key

§

D8

8 key

§

D9

9 key

§

Num0

Numpad 0 key

§

Num1

Numpad 1 key

§

Num2

Numpad 2 key

§

Num3

Numpad 3 key

§

Num4

Numpad 4 key

§

Num5

Numpad 5 key

§

Num6

Numpad 6 key

§

Num7

Numpad 7 key

§

Num8

Numpad 8 key

§

Num9

Numpad 9 key

§

NumMultiply

Numpad multiply key

§

NumAdd

Numpad add key

§

NumSubtract

Numpad subtract key

§

NumDivide

Numpad divide key

§

NumDecimal

Numpad decimal key

§

F1

F1 key

§

F2

F2 key

§

F3

F3 key

§

F4

F4 key

§

F5

F5 key

§

F6

F6 key

§

F7

F7 key

§

F8

F8 key

§

F9

F9 key

§

F10

F10 key

§

F11

F11 key

§

F12

F12 key

§

F13

F13 key

§

F14

F14 key

§

F15

F15 key

§

F16

F16 key

§

F17

F17 key

§

F18

F18 key

§

F19

F19 key

§

F20

F20 key

§

F21

F21 key

§

F22

F22 key

§

F23

F23 key

§

F24

F24 key

§

CapsLock

Caps Lock key

§

NumLock

Num Lock key

§

ScrollLock

Scroll Lock key

§

Pause

Pause/Break key

§

Apps

Application/Context Menu key

§

Sleep

Sleep key

§

MediaPlayPause

Media Play/Pause key

§

MediaStop

Media Stop key

§

MediaNext

Media Next Track key

§

MediaPrevious

Media Previous Track key

§

VolumeUp

Volume Up key

§

VolumeDown

Volume Down key

§

VolumeMute

Volume Mute key

§

BrowserBack

Browser Back key

§

BrowserForward

Browser Forward key

§

BrowserRefresh

Browser Refresh key

§

BrowserHome

Browser Home key

Implementations§

Source§

impl Key

Source

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

Get the string representation of the key

Examples found in repository?
examples/game_input_system.rs (line 127)
124    fn list_bindings(&self) {
125        println!("\n普通键绑定:");
126        let mut keys: Vec<_> = self.key_bindings.iter().collect();
127        keys.sort_by_key(|(key, _)| key.as_str());
128        for (key, action) in keys {
129            println!("  {:15} -> {:?}", key, action);
130        }
131
132        println!("\n修饰键绑定:");
133        let mut modifiers: Vec<_> = self.modifier_bindings.iter().collect();
134        modifiers.sort_by_key(|(modifier, _)| modifier.as_str());
135        for (modifier, action) in modifiers {
136            println!("  {:15} -> {:?}", modifier, action);
137        }
138    }

Trait Implementations§

Source§

impl Clone for Key

Source§

fn clone(&self) -> Key

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 Key

Source§

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

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

impl Display for Key

Source§

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

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

impl FromStr for Key

Source§

type Err = KeyParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Key

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 KeyCodeMapper for Key

Source§

fn to_code(&self, platform: Platform) -> usize

Convert the key or modifier to a platform-specific code
Source§

fn from_code(code: usize, platform: Platform) -> Option<Self>

Parse a key or modifier from a platform-specific code
Source§

impl PartialEq for Key

Source§

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

Source§

impl Eq for Key

Source§

impl StructuralPartialEq for Key

Auto Trait Implementations§

§

impl Freeze for Key

§

impl RefUnwindSafe for Key

§

impl Send for Key

§

impl Sync for Key

§

impl Unpin 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<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.