#[repr(C)]pub enum PhysicalKey {
Show 127 variants
Unidentified = 0,
KeyA = 1,
KeyB = 2,
KeyC = 3,
KeyD = 4,
KeyE = 5,
KeyF = 6,
KeyG = 7,
KeyH = 8,
KeyI = 9,
KeyJ = 10,
KeyK = 11,
KeyL = 12,
KeyM = 13,
KeyN = 14,
KeyO = 15,
KeyP = 16,
KeyQ = 17,
KeyR = 18,
KeyS = 19,
KeyT = 20,
KeyU = 21,
KeyV = 22,
KeyW = 23,
KeyX = 24,
KeyY = 25,
KeyZ = 26,
Digit0 = 27,
Digit1 = 28,
Digit2 = 29,
Digit3 = 30,
Digit4 = 31,
Digit5 = 32,
Digit6 = 33,
Digit7 = 34,
Digit8 = 35,
Digit9 = 36,
Backquote = 37,
Minus = 38,
Equal = 39,
BracketLeft = 40,
BracketRight = 41,
Backslash = 42,
Semicolon = 43,
Quote = 44,
Comma = 45,
Period = 46,
Slash = 47,
Enter = 48,
Tab = 49,
Space = 50,
Backspace = 51,
Escape = 52,
CapsLock = 53,
ShiftLeft = 54,
ShiftRight = 55,
ControlLeft = 56,
ControlRight = 57,
AltLeft = 58,
AltRight = 59,
MetaLeft = 60,
MetaRight = 61,
ContextMenu = 62,
Insert = 63,
Delete = 64,
Home = 65,
End = 66,
PageUp = 67,
PageDown = 68,
ArrowUp = 69,
ArrowDown = 70,
ArrowLeft = 71,
ArrowRight = 72,
F1 = 73,
F2 = 74,
F3 = 75,
F4 = 76,
F5 = 77,
F6 = 78,
F7 = 79,
F8 = 80,
F9 = 81,
F10 = 82,
F11 = 83,
F12 = 84,
F13 = 85,
F14 = 86,
F15 = 87,
F16 = 88,
F17 = 89,
F18 = 90,
F19 = 91,
F20 = 92,
F21 = 93,
F22 = 94,
F23 = 95,
F24 = 96,
PrintScreen = 97,
ScrollLock = 98,
Pause = 99,
NumLock = 100,
NumpadDivide = 101,
NumpadMultiply = 102,
NumpadSubtract = 103,
NumpadAdd = 104,
NumpadEnter = 105,
NumpadDecimal = 106,
NumpadComma = 107,
NumpadEqual = 108,
Numpad0 = 109,
Numpad1 = 110,
Numpad2 = 111,
Numpad3 = 112,
Numpad4 = 113,
Numpad5 = 114,
Numpad6 = 115,
Numpad7 = 116,
Numpad8 = 117,
Numpad9 = 118,
IntlBackslash = 119,
IntlRo = 120,
IntlYen = 121,
Lang1 = 122,
Lang2 = 123,
Convert = 124,
NonConvert = 125,
KanaMode = 126,
}Expand description
A key identified by its PHYSICAL POSITION, independent of layout.
The companion to VirtualKeyCode, which is the LOGICAL key — what the
user’s layout says that position produces. Every modern stack splits these
because they answer different questions: KeyboardEvent.code vs .key on
the web, PhysicalKey vs Key in winit.
ScanCode already carried the physical key as a raw u32, but a raw
scancode is platform-specific and unnameable — an app cannot write
if scancode == 17 and mean anything portable. This is the same
information in a form that can be matched on.
Names follow the W3C UI Events code values, which name each position by
what it produces on US ANSI. KeyW is “the key where W sits on a US
board” — on AZERTY the user sees Z there, and a game binding “forward”
wants that position regardless.
Variants§
Unidentified = 0
The platform reported a position this enum does not name.
KeyA = 1
KeyB = 2
KeyC = 3
KeyD = 4
KeyE = 5
KeyF = 6
KeyG = 7
KeyH = 8
KeyI = 9
KeyJ = 10
KeyK = 11
KeyL = 12
KeyM = 13
KeyN = 14
KeyO = 15
KeyP = 16
KeyQ = 17
KeyR = 18
KeyS = 19
KeyT = 20
KeyU = 21
KeyV = 22
KeyW = 23
KeyX = 24
KeyY = 25
KeyZ = 26
Digit0 = 27
Digit1 = 28
Digit2 = 29
Digit3 = 30
Digit4 = 31
Digit5 = 32
Digit6 = 33
Digit7 = 34
Digit8 = 35
Digit9 = 36
Backquote = 37
Minus = 38
Equal = 39
BracketLeft = 40
BracketRight = 41
Backslash = 42
Semicolon = 43
Quote = 44
Comma = 45
Period = 46
Slash = 47
Enter = 48
Tab = 49
Space = 50
Backspace = 51
Escape = 52
CapsLock = 53
ShiftLeft = 54
ShiftRight = 55
ControlLeft = 56
ControlRight = 57
AltLeft = 58
AltRight = 59
MetaLeft = 60
MetaRight = 61
ContextMenu = 62
Insert = 63
Delete = 64
Home = 65
End = 66
PageUp = 67
PageDown = 68
ArrowUp = 69
ArrowDown = 70
ArrowLeft = 71
ArrowRight = 72
F1 = 73
F2 = 74
F3 = 75
F4 = 76
F5 = 77
F6 = 78
F7 = 79
F8 = 80
F9 = 81
F10 = 82
F11 = 83
F12 = 84
F13 = 85
F14 = 86
F15 = 87
F16 = 88
F17 = 89
F18 = 90
F19 = 91
F20 = 92
F21 = 93
F22 = 94
F23 = 95
F24 = 96
PrintScreen = 97
ScrollLock = 98
Pause = 99
NumLock = 100
NumpadDivide = 101
NumpadMultiply = 102
NumpadSubtract = 103
NumpadAdd = 104
NumpadEnter = 105
NumpadDecimal = 106
NumpadComma = 107
NumpadEqual = 108
Numpad0 = 109
Numpad1 = 110
Numpad2 = 111
Numpad3 = 112
Numpad4 = 113
Numpad5 = 114
Numpad6 = 115
Numpad7 = 116
Numpad8 = 117
Numpad9 = 118
IntlBackslash = 119
IntlRo = 120
IntlYen = 121
Lang1 = 122
Lang2 = 123
Convert = 124
NonConvert = 125
KanaMode = 126
Implementations§
Source§impl PhysicalKey
impl PhysicalKey
Sourcepub const fn from_evdev(code: u32) -> Self
pub const fn from_evdev(code: u32) -> Self
Linux evdev keycode -> position.
Used directly by Wayland and Android. X11 callers must pass
keycode - 8; see Self::from_x11_keycode.
Sourcepub const fn from_x11_keycode(keycode: u32) -> Self
pub const fn from_x11_keycode(keycode: u32) -> Self
X11 keycode -> position.
XKB keycodes are evdev + 8 by protocol, so this is the evdev table
with the offset removed. A keycode below 8 cannot be an evdev key and
is reported as unidentified rather than wrapping into a wrong one.
Sourcepub const fn from_windows_scancode(scancode: u32, extended: bool) -> Self
pub const fn from_windows_scancode(scancode: u32, extended: bool) -> Self
PS/2 set-1 scancode -> position, as WM_KEYDOWN reports it.
extended is lParam bit 24 (the E0 prefix). It is not optional
detail: without it Enter and NumpadEnter, ControlLeft and ControlRight,
and the whole arrow cluster versus the numpad are the SAME scancode.
Sourcepub const fn from_macos_keycode(keycode: u16) -> Self
pub const fn from_macos_keycode(keycode: u16) -> Self
Carbon virtual keycode (NSEvent.keyCode) -> position.
Cross-checked entry by entry against
macos_keycode_to_virtual_key, the table this codebase already
trusts for the LOGICAL key; the two agree on every code both name.
Trait Implementations§
Source§impl Clone for PhysicalKey
impl Clone for PhysicalKey
Source§fn clone(&self) -> PhysicalKey
fn clone(&self) -> PhysicalKey
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more