pub enum Key {
}Expand description
A keyboard key.
Modifier keys (Shift, Ctrl, Alt, Meta) are regular variants of this
enum — they are not a separate type. This matches the physical reality that
modifiers are keys like any other, and the convention of Playwright,
Puppeteer, Selenium, pyautogui, SendInput, and XTest.
§Key::Char semantics
Key::Char(c) represents the physical key labeled with the unshifted
character c. It does not auto-synthesise Shift. To produce an
uppercase letter or shifted symbol, hold Key::Shift explicitly:
// Cmd+A (select all):
keyboard.chord(Key::Char('a'), &[Key::Meta]);
// Uppercase 'A':
keyboard.chord(Key::Char('a'), &[Key::Shift]);For this reason, Key::Char rejects ASCII uppercase letters at the API
boundary (Error::InvalidActionData). This prevents the common
footgun where chord(Key::Char('K'), &[Key::Meta]) is read as “Cmd+K”
but would silently mean “Cmd+Shift+K” under auto-shift semantics.
To type arbitrary text (with IME support and correct case handling), use
Keyboard::type_text — Key is for single-key presses.
§Meta
Meta is the platform’s “command” modifier: Cmd on macOS, Win on Windows,
Super on Linux. Backends are responsible for the platform mapping.
Variants§
Char(char)
A printable character (lowercase, no shifted symbols). Backends translate this to the matching physical key. See the type-level docs for the rationale on rejecting uppercase letters.
Shift
Ctrl
Alt
Meta
Enter
Escape
Backspace
Tab
Space
Delete
Insert
ArrowUp
ArrowDown
ArrowLeft
ArrowRight
Home
End
PageUp
PageDown
F(u8)
A function key. n is 1-based (F(1) = F1).