#[non_exhaustive]pub enum KeyCode {
Show 107 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,
Space,
Backspace,
Enter,
Delete,
Insert,
ShiftLeft,
ShiftRight,
ControlLeft,
ControlRight,
AltLeft,
AltRight,
SuperLeft,
SuperRight,
ContextMenu,
Home,
End,
PageUp,
PageDown,
ArrowUp,
ArrowDown,
ArrowLeft,
ArrowRight,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
PrintScreen,
ScrollLock,
Pause,
NumLock,
Numpad0,
Numpad1,
Numpad2,
Numpad3,
Numpad4,
Numpad5,
Numpad6,
Numpad7,
Numpad8,
Numpad9,
NumpadDivide,
NumpadMultiply,
NumpadSubtract,
NumpadAdd,
NumpadEnter,
NumpadDecimal,
}Expand description
A key identified by physical position, independent of keyboard layout.
Variant names follow the W3C UI Events code values, which name
positions after the US-QWERTY legends: KeyCode::KeyW is the key
where W is on a US keyboard, which on AZERTY is the key labelled
Z. That is precisely the property gameplay bindings want — WASD
stays a square under the left hand everywhere — and precisely the
property a rebind menu must not display, which is what
Keysym is for.
§Non-exhaustive on purpose
Unlike SurfaceTarget, which is exhaustive
so that a new platform breaks every backend loudly, this enum is
#[non_exhaustive]: consumers match a handful of keys and fall
through on the rest, so adding a key must not be a breaking change.
A key nobody named is a key nobody bound, which degrades to “the
binding does not fire” — not to a wrong action.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
KeyA
The KeyA key.
KeyB
The KeyB key.
KeyC
The KeyC key.
KeyD
The KeyD key.
KeyE
The KeyE key.
KeyF
The KeyF key.
KeyG
The KeyG key.
KeyH
The KeyH key.
KeyI
The KeyI key.
KeyJ
The KeyJ key.
KeyK
The KeyK key.
KeyL
The KeyL key.
KeyM
The KeyM key.
KeyN
The KeyN key.
KeyO
The KeyO key.
KeyP
The KeyP key.
KeyQ
The KeyQ key.
KeyR
The KeyR key.
KeyS
The KeyS key.
KeyT
The KeyT key.
KeyU
The KeyU key.
KeyV
The KeyV key.
KeyW
The KeyW key.
KeyX
The KeyX key.
KeyY
The KeyY key.
KeyZ
The KeyZ key.
Digit0
The Digit0 key.
Digit1
The Digit1 key.
Digit2
The Digit2 key.
Digit3
The Digit3 key.
Digit4
The Digit4 key.
Digit5
The Digit5 key.
Digit6
The Digit6 key.
Digit7
The Digit7 key.
Digit8
The Digit8 key.
Digit9
The Digit9 key.
Backquote
The Backquote key.
Minus
The Minus key.
Equal
The Equal key.
BracketLeft
The BracketLeft key.
BracketRight
The BracketRight key.
Backslash
The Backslash key.
Semicolon
The Semicolon key.
Quote
The Quote key.
Comma
The Comma key.
Period
The Period key.
Slash
The Slash key.
IntlBackslash
The IntlBackslash key.
IntlRo
The IntlRo key.
IntlYen
The IntlYen key.
Escape
The Escape key.
Tab
The Tab key.
CapsLock
The CapsLock key.
Space
The Space key.
Backspace
The Backspace key.
Enter
The Enter key.
Delete
The Delete key.
Insert
The Insert key.
ShiftLeft
The ShiftLeft key.
ShiftRight
The ShiftRight key.
ControlLeft
The ControlLeft key.
ControlRight
The ControlRight key.
AltLeft
The AltLeft key.
AltRight
The AltRight key.
SuperLeft
The SuperLeft key.
SuperRight
The SuperRight key.
ContextMenu
The ContextMenu key.
Home
The Home key.
End
The End key.
PageUp
The PageUp key.
PageDown
The PageDown key.
ArrowUp
The ArrowUp key.
ArrowDown
The ArrowDown key.
ArrowLeft
The ArrowLeft key.
ArrowRight
The ArrowRight key.
F1
The F1 key.
F2
The F2 key.
F3
The F3 key.
F4
The F4 key.
F5
The F5 key.
F6
The F6 key.
F7
The F7 key.
F8
The F8 key.
F9
The F9 key.
F10
The F10 key.
F11
The F11 key.
F12
The F12 key.
PrintScreen
The PrintScreen key.
ScrollLock
The ScrollLock key.
Pause
The Pause key.
NumLock
The NumLock key.
Numpad0
The Numpad0 key.
Numpad1
The Numpad1 key.
Numpad2
The Numpad2 key.
Numpad3
The Numpad3 key.
Numpad4
The Numpad4 key.
Numpad5
The Numpad5 key.
Numpad6
The Numpad6 key.
Numpad7
The Numpad7 key.
Numpad8
The Numpad8 key.
Numpad9
The Numpad9 key.
NumpadDivide
The NumpadDivide key.
NumpadMultiply
The NumpadMultiply key.
NumpadSubtract
The NumpadSubtract key.
NumpadAdd
The NumpadAdd key.
NumpadEnter
The NumpadEnter key.
NumpadDecimal
The NumpadDecimal key.
Implementations§
Source§impl KeyCode
impl KeyCode
Sourcepub const ALL: &'static [KeyCode]
pub const ALL: &'static [KeyCode]
Every key this engine has a name for, in declaration order.
Used by the rebind UI to enumerate choices and by tests to prove the name table round-trips.
Sourcepub const fn as_str(self) -> &'static str
pub const fn as_str(self) -> &'static str
The stable name of this key, as written in binding assets and profiles.
Stable across releases: it is a serialization format, not a display string. A rebind menu shows the keysym, not this.
Sourcepub fn from_name(name: &str) -> Option<KeyCode>
pub fn from_name(name: &str) -> Option<KeyCode>
Parses a name produced by KeyCode::as_str.
Not a FromStr impl: the only possible
failure is “no such key”, and an error type carrying that one
fact would be ceremony. Bindings for unknown names are kept as
Scancode by the profile loader
rather than dropped.