#[non_exhaustive]pub enum Key {
}Expand description
A key on the keyboard, as KeyEvent::key names it (docs/menus.md “Keys”).
A key that types is Key::Character with its unmodified character ('a', 'A' under
Shift, '8', 'ü' on a layout that has one, ' ' for the space bar); a key that types
nothing is one of the named variants. Key::Unidentified stands for text with no single
key behind it (an input method’s commit) and for a key outside this vocabulary.
At the boundaries that stay text (a backend’s wire, a dayscript key: step, a menu
Shortcut) a key is spelled by its web KeyboardEvent.key name: Key::from_name
reads one and Key::name writes it.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Character(char)
A key that types, named by its unmodified character.
ArrowLeft
ArrowRight
ArrowUp
ArrowDown
Enter
Tab
Escape
Backspace
Delete
Home
End
PageUp
PageDown
Insert
F(u8)
A function key, F(1) through F(12).
Unidentified
No single key: text an input method committed, or a key this vocabulary does not name.
Implementations§
Source§impl Key
impl Key
Sourcepub fn from_name(name: &str) -> Key
pub fn from_name(name: &str) -> Key
The key a web KeyboardEvent.key name spells: a named key, "F1" through "F12", a
single character, or "Space" for the space bar. Anything else is
Key::Unidentified.
Sourcepub fn name(self) -> String
pub fn name(self) -> String
The web KeyboardEvent.key name of this key: "ArrowLeft", "F5", "a", and the
empty string for Key::Unidentified. The inverse of Key::from_name.
Sourcepub fn character(self) -> Option<char>
pub fn character(self) -> Option<char>
The character of a key that types, or None for a named key.
Sourcepub fn digit(self) -> Option<u8>
pub fn digit(self) -> Option<u8>
The value of a digit key ('0' through '9'), or None for every other key.
Sourcepub fn shortcut_name(self) -> String
pub fn shortcut_name(self) -> String
The name a menu Shortcut spells this key with ("Return", "Left", "F1",
"s"): the menu vocabulary every backend’s accelerator table reads, which differs
from the web names for Enter and the arrows.
Trait Implementations§
impl Copy for Key
impl Eq for Key
Source§impl From<&str> for Key
A key by its web name (Key::from_name): what a backend’s key table and a scripted
step hold.
impl From<&str> for Key
A key by its web name (Key::from_name): what a backend’s key table and a scripted
step hold.