pub enum Key {
Show 68 variants
Space,
Enter,
Escape,
Tab,
Backspace,
Delete,
Insert,
ArrowUp,
ArrowDown,
ArrowLeft,
ArrowRight,
Home,
End,
PageUp,
PageDown,
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,
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,
ContextMenu,
Character(char),
}Expand description
Keyboard key identifiers.
Variants§
Space
Enter
Escape
Tab
Backspace
Delete
Insert
ArrowUp
ArrowDown
ArrowLeft
ArrowRight
Home
End
PageUp
PageDown
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
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
Caps Lock. Delivered as a discrete key press/release (winit’s
ModifiersState does not carry lock state), so consumers that
need the active lock state track it themselves on the
key-down edge. See WindowState::caps_lock.
ContextMenu
The dedicated context-menu key: VK_APPS on Windows (the key between
the right Alt and the right Ctrl on most PC layouts), keysyms::Menu on
X11 and Wayland.
macOS never produces it. Its keyboards have no such key and
winit-0.30.13’s AppKit backend references the variant zero times, so
on that platform the only keyboard route to a context menu is a chord.
See the dispatcher’s context-menu handling for the chords Teksilo
reserves.
Character(char)
Implementations§
Source§impl Key
impl Key
Sourcepub fn to_char(&self) -> Option<char>
pub fn to_char(&self) -> Option<char>
Returns the character this key represents, if any.
Maps Key::A..Key::Z to 'a'..'z' (lowercase) and
Key::Character(ch) to ch.
Sourcepub fn to_text(&self) -> Option<&'static str>
pub fn to_text(&self) -> Option<&'static str>
The text the platform attaches to this key, for the handful of named
keys that carry any. Mirrors winit’s NamedKey::to_text, which is
where these values reach the app from.
Worth knowing because it is surprising: Escape arrives carrying
U+001B, so a widget that reads KeyDown::text sees text on a key
nobody thinks of as text. A TextInputField used to filter that
control character out, read the empty result as “input rejected” and
swallow the key — which is how Escape stopped bubbling out of a
focused field.
Character keys are deliberately absent: Key::A is None here, and
the way to simulate typing is type_text, which already sends text.
The gap this closes is only the surprising one.