// copy from keyboard-types = "0.7"
// AUTO GENERATED CODE - DO NOT EDIT
#![cfg_attr(rustfmt, rustfmt_skip)]
use std::fmt::{self, Display};
use std::str::FromStr;
use std::error::Error;
/// Code is the physical position of a key.
///
/// The names are based on the US keyboard. If the key
/// is not present on US keyboards a name from another
/// layout is used.
///
/// Specification:
///
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub enum Code {
/// `~
on a US keyboard. This is the 半角/全角/漢字
(hankaku/zenkaku/kanji) key on Japanese keyboards
Backquote,
/// Used for both the US \|
(on the 101-key layout) and also for the key
/// located between the "
and Enter
keys on row C of the 102-,
/// 104- and 106-key layouts.
/// Labelled #~
on a UK (102) keyboard.
Backslash,
/// [{
on a US keyboard.
BracketLeft,
/// ]}
on a US keyboard.
BracketRight,
/// ,<
on a US keyboard.
Comma,
/// 0)
on a US keyboard.
Digit0,
/// 1!
on a US keyboard.
Digit1,
/// 2@
on a US keyboard.
Digit2,
/// 3#
on a US keyboard.
Digit3,
/// 4$
on a US keyboard.
Digit4,
/// 5%
on a US keyboard.
Digit5,
/// 6^
on a US keyboard.
Digit6,
/// 7&
on a US keyboard.
Digit7,
/// 8*
on a US keyboard.
Digit8,
/// 9(
on a US keyboard.
Digit9,
/// =+
on a US keyboard.
Equal,
/// Located between the left Shift
and Z
keys.
/// Labelled \|
on a UK keyboard.
IntlBackslash,
/// Located between the /
and right Shift
keys.
/// Labelled \ろ
(ro) on a Japanese keyboard.
IntlRo,
/// Located between the =
and Backspace
keys.
/// Labelled ¥
(yen) on a Japanese keyboard. \/
on a
/// Russian keyboard.
IntlYen,
/// a
on a US keyboard.
/// Labelled q
on an AZERTY (e.g., French) keyboard.
KeyA,
/// b
on a US keyboard.
KeyB,
/// c
on a US keyboard.
KeyC,
/// d
on a US keyboard.
KeyD,
/// e
on a US keyboard.
KeyE,
/// f
on a US keyboard.
KeyF,
/// g
on a US keyboard.
KeyG,
/// h
on a US keyboard.
KeyH,
/// i
on a US keyboard.
KeyI,
/// j
on a US keyboard.
KeyJ,
/// k
on a US keyboard.
KeyK,
/// l
on a US keyboard.
KeyL,
/// m
on a US keyboard.
KeyM,
/// n
on a US keyboard.
KeyN,
/// o
on a US keyboard.
KeyO,
/// p
on a US keyboard.
KeyP,
/// q
on a US keyboard.
/// Labelled a
on an AZERTY (e.g., French) keyboard.
KeyQ,
/// r
on a US keyboard.
KeyR,
/// s
on a US keyboard.
KeyS,
/// t
on a US keyboard.
KeyT,
/// u
on a US keyboard.
KeyU,
/// v
on a US keyboard.
KeyV,
/// w
on a US keyboard.
/// Labelled z
on an AZERTY (e.g., French) keyboard.
KeyW,
/// x
on a US keyboard.
KeyX,
/// y
on a US keyboard.
/// Labelled z
on a QWERTZ (e.g., German) keyboard.
KeyY,
/// z
on a US keyboard.
/// Labelled w
on an AZERTY (e.g., French) keyboard, and y
on a
/// QWERTZ (e.g., German) keyboard.
KeyZ,
/// -_
on a US keyboard.
Minus,
/// .>
on a US keyboard.
Period,
/// '"
on a US keyboard.
Quote,
/// ;:
on a US keyboard.
Semicolon,
/// /?
on a US keyboard.
Slash,
/// Alt
, Option
or ⌥
.
AltLeft,
/// Alt
, Option
or ⌥
.
/// This is labelled AltGr
key on many keyboard layouts.
AltRight,
/// Backspace
or ⌫
.
/// Labelled Delete
on Apple keyboards.
Backspace,
/// CapsLock
or ⇪
CapsLock,
/// The application context menu key, which is typically found between the right Meta
key and the right Control
key.
ContextMenu,
/// Control
or ⌃
ControlLeft,
/// Control
or ⌃
ControlRight,
/// Enter
or ↵
. Labelled Return
on Apple keyboards.
Enter,
/// The Windows, ⌘
, Command
or other OS symbol key.
MetaLeft,
/// The Windows, ⌘
, Command
or other OS symbol key.
MetaRight,
/// Shift
or ⇧
ShiftLeft,
/// Shift
or ⇧
ShiftRight,
///
(space)
Space,
/// Tab
or ⇥
Tab,
/// Japanese: 変換
(henkan)
Convert,
/// Japanese: カタカナ/ひらがな/ローマ字
(katakana/hiragana/romaji)
KanaMode,
/// Korean: HangulMode 한/영
(han/yeong)
Japanese (Mac keyboard): かな
(kana)
Lang1,
/// Korean: Hanja 한자
(hanja)
Japanese (Mac keyboard): 英数
(eisu)
Lang2,
/// Japanese (word-processing keyboard): Katakana
Lang3,
/// Japanese (word-processing keyboard): Hiragana
Lang4,
/// Japanese (word-processing keyboard): Zenkaku/Hankaku
Lang5,
/// Japanese: 無変換
(muhenkan)
NonConvert,
/// ⌦
. The forward delete key.
/// Note that on Apple keyboards, the key labelled Delete
on the main part of
/// the keyboard should be encoded as "Backspace"
.
Delete,
/// End
or ↘
End,
/// Help
. Not present on standard PC keyboards.
Help,
/// Home
or ↖
Home,
/// Insert
or Ins
. Not present on Apple keyboards.
Insert,
/// Page Down
, PgDn
or ⇟
PageDown,
/// Page Up
, PgUp
or ⇞
PageUp,
/// ↓
ArrowDown,
/// ←
ArrowLeft,
/// →
ArrowRight,
/// ↑
ArrowUp,
/// On the Mac, the "NumLock"
code should be used for the numpad Clear
key.
NumLock,
/// 0 Ins
on a keyboard
0
on a phone or remote control
Numpad0,
/// 1 End
on a keyboard
1
or 1 QZ
on a phone or
/// remote control
Numpad1,
/// 2 ↓
on a keyboard
2 ABC
on a phone or remote control
Numpad2,
/// 3 PgDn
on a keyboard
3 DEF
on a phone or remote control
Numpad3,
/// 4 ←
on a keyboard
4 GHI
on a phone or remote control
Numpad4,
/// 5
on a keyboard
5 JKL
on a phone or remote control
Numpad5,
/// 6 →
on a keyboard
6 MNO
on a phone or remote control
Numpad6,
/// 7 Home
on a keyboard
7 PQRS
or 7 PRS
on a phone
/// or remote control
Numpad7,
/// 8 ↑
on a keyboard
8 TUV
on a phone or remote control
Numpad8,
/// 9 PgUp
on a keyboard
9 WXYZ
or 9 WXY
on a phone
/// or remote control
Numpad9,
/// +
NumpadAdd,
/// Found on the Microsoft Natural Keyboard.
NumpadBackspace,
/// C
or AC
(All Clear). Also for use with numpads that have a Clear
key that is separate from the NumLock
key. On the Mac, the numpad Clear
key should always
/// be encoded as "NumLock"
.
NumpadClear,
/// CE
(Clear Entry)
NumpadClearEntry,
/// ,
(thousands separator). For locales where the thousands separator
/// is a "." (e.g., Brazil), this key may generate a .
.
NumpadComma,
/// . Del
. For locales where the decimal separator is "," (e.g.,
/// Brazil), this key may generate a ,
.
NumpadDecimal,
/// /
NumpadDivide,
NumpadEnter,
/// =
NumpadEqual,
/// #
on a phone or remote control device. This key is typically found
/// below the 9
key and to the right of the 0
key.
NumpadHash,
/// M+
Add current entry to the value stored in memory.
NumpadMemoryAdd,
/// MC
Clear the value stored in memory.
NumpadMemoryClear,
/// MR
Replace the current entry with the value stored in memory.
NumpadMemoryRecall,
/// MS
Replace the value stored in memory with the current entry.
NumpadMemoryStore,
/// M-
Subtract current entry from the value stored in memory.
NumpadMemorySubtract,
/// *
on a keyboard. For use with numpads that provide mathematical
/// operations (+
, -
, *
and /
).
Use "NumpadStar"
for the *
key on phones and remote controls.
NumpadMultiply,
/// (
Found on the Microsoft Natural Keyboard.
NumpadParenLeft,
/// )
Found on the Microsoft Natural Keyboard.
NumpadParenRight,
/// *
on a phone or remote control device.
/// This key is typically found below the 7
key and to the left of
/// the 0
key.
Use "NumpadMultiply"
for the *
key on
/// numeric keypads.
NumpadStar,
/// -
NumpadSubtract,
/// Esc
or ⎋
Escape,
/// Fn
This is typically a hardware key that does not generate a separate
/// code. Most keyboards do not place this key in the function section, but it is
/// included here to keep it with related keys.
Fn,
/// FLock
or FnLock
. Function Lock key. Found on the Microsoft
/// Natural Keyboard.
FnLock,
/// PrtScr SysRq
or Print Screen
PrintScreen,
/// Scroll Lock
ScrollLock,
/// Pause Break
Pause,
/// Some laptops place this key to the left of the ↑
key.
BrowserBack,
BrowserFavorites,
/// Some laptops place this key to the right of the ↑
key.
BrowserForward,
BrowserHome,
BrowserRefresh,
BrowserSearch,
BrowserStop,
/// Eject
or ⏏
. This key is placed in the function
/// section on some Apple keyboards.
Eject,
/// Sometimes labelled My Computer
on the keyboard
LaunchApp1,
/// Sometimes labelled Calculator
on the keyboard
LaunchApp2,
LaunchMail,
MediaPlayPause,
MediaSelect,
MediaStop,
MediaTrackNext,
MediaTrackPrevious,
/// This key is placed in the function section on some Apple keyboards,
/// replacing the Eject
key.
Power,
Sleep,
AudioVolumeDown,
AudioVolumeMute,
AudioVolumeUp,
WakeUp,
Hyper,
Super,
Turbo,
Abort,
Resume,
Suspend,
/// Found on Sun’s USB keyboard.
Again,
/// Found on Sun’s USB keyboard.
Copy,
/// Found on Sun’s USB keyboard.
Cut,
/// Found on Sun’s USB keyboard.
Find,
/// Found on Sun’s USB keyboard.
Open,
/// Found on Sun’s USB keyboard.
Paste,
/// Found on Sun’s USB keyboard.
Props,
/// Found on Sun’s USB keyboard.
Select,
/// Found on Sun’s USB keyboard.
Undo,
/// Use for dedicated ひらがな
key found on some Japanese word processing keyboards.
Hiragana,
/// Use for dedicated カタカナ
key found on some Japanese word processing keyboards.
Katakana,
/// This value code should be used when no other
/// value given in this specification is appropriate.
Unidentified(u16),
/// F1
F1,
/// F2
F2,
/// F3
F3,
/// F4
F4,
/// F5
F5,
/// F6
F6,
/// F7
F7,
/// F8
F8,
/// F9
F9,
/// F10
F10,
/// F11
F11,
/// F12
F12,
/// F13
F13,
/// F14
F14,
/// F15
F15,
/// F16
F16,
/// F17
F17,
/// F18
F18,
/// F19
F19,
/// F20
F20,
/// F21
F21,
/// F22
F22,
/// F23
F23,
/// F24
F24,
/// F25
F25,
/// F26
F26,
/// F27
F27,
/// F28
F28,
/// F29
F29,
/// F30
F30,
/// F31
F31,
/// F32
F32,
/// F33
F33,
/// F34
F34,
/// F35
F35,
/// Non-standard code value supported by Chromium.
BrightnessDown,
/// Non-standard code value supported by Chromium.
BrightnessUp,
/// Non-standard code value supported by Chromium.
DisplayToggleIntExt,
/// Non-standard code value supported by Chromium.
KeyboardLayoutSelect,
/// Non-standard code value supported by Chromium.
LaunchAssistant,
/// Non-standard code value supported by Chromium.
LaunchControlPanel,
/// Non-standard code value supported by Chromium.
LaunchScreenSaver,
/// Non-standard code value supported by Chromium.
MailForward,
/// Non-standard code value supported by Chromium.
MailReply,
/// Non-standard code value supported by Chromium.
MailSend,
/// Non-standard code value supported by Chromium.
MediaFastForward,
/// Non-standard code value supported by Chromium.
MediaPause,
/// Non-standard code value supported by Chromium.
MediaPlay,
/// Non-standard code value supported by Chromium.
MediaRecord,
/// Non-standard code value supported by Chromium.
MediaRewind,
/// Non-standard code value supported by Chromium.
MicrophoneMuteToggle,
/// Non-standard code value supported by Chromium.
PrivacyScreenToggle,
/// Non-standard code value supported by Chromium.
SelectTask,
/// Non-standard code value supported by Chromium.
ShowAllWindows,
/// Non-standard code value supported by Chromium.
ZoomToggle,
}
impl Display for Code {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use self::Code::*;
match *self {
Backquote => f.write_str("Backquote"),
Backslash => f.write_str("Backslash"),
BracketLeft => f.write_str("BracketLeft"),
BracketRight => f.write_str("BracketRight"),
Comma => f.write_str("Comma"),
Digit0 => f.write_str("Digit0"),
Digit1 => f.write_str("Digit1"),
Digit2 => f.write_str("Digit2"),
Digit3 => f.write_str("Digit3"),
Digit4 => f.write_str("Digit4"),
Digit5 => f.write_str("Digit5"),
Digit6 => f.write_str("Digit6"),
Digit7 => f.write_str("Digit7"),
Digit8 => f.write_str("Digit8"),
Digit9 => f.write_str("Digit9"),
Equal => f.write_str("Equal"),
IntlBackslash => f.write_str("IntlBackslash"),
IntlRo => f.write_str("IntlRo"),
IntlYen => f.write_str("IntlYen"),
KeyA => f.write_str("KeyA"),
KeyB => f.write_str("KeyB"),
KeyC => f.write_str("KeyC"),
KeyD => f.write_str("KeyD"),
KeyE => f.write_str("KeyE"),
KeyF => f.write_str("KeyF"),
KeyG => f.write_str("KeyG"),
KeyH => f.write_str("KeyH"),
KeyI => f.write_str("KeyI"),
KeyJ => f.write_str("KeyJ"),
KeyK => f.write_str("KeyK"),
KeyL => f.write_str("KeyL"),
KeyM => f.write_str("KeyM"),
KeyN => f.write_str("KeyN"),
KeyO => f.write_str("KeyO"),
KeyP => f.write_str("KeyP"),
KeyQ => f.write_str("KeyQ"),
KeyR => f.write_str("KeyR"),
KeyS => f.write_str("KeyS"),
KeyT => f.write_str("KeyT"),
KeyU => f.write_str("KeyU"),
KeyV => f.write_str("KeyV"),
KeyW => f.write_str("KeyW"),
KeyX => f.write_str("KeyX"),
KeyY => f.write_str("KeyY"),
KeyZ => f.write_str("KeyZ"),
Minus => f.write_str("Minus"),
Period => f.write_str("Period"),
Quote => f.write_str("Quote"),
Semicolon => f.write_str("Semicolon"),
Slash => f.write_str("Slash"),
AltLeft => f.write_str("AltLeft"),
AltRight => f.write_str("AltRight"),
Backspace => f.write_str("Backspace"),
CapsLock => f.write_str("CapsLock"),
ContextMenu => f.write_str("ContextMenu"),
ControlLeft => f.write_str("ControlLeft"),
ControlRight => f.write_str("ControlRight"),
Enter => f.write_str("Enter"),
MetaLeft => f.write_str("MetaLeft"),
MetaRight => f.write_str("MetaRight"),
ShiftLeft => f.write_str("ShiftLeft"),
ShiftRight => f.write_str("ShiftRight"),
Space => f.write_str("Space"),
Tab => f.write_str("Tab"),
Convert => f.write_str("Convert"),
KanaMode => f.write_str("KanaMode"),
Lang1 => f.write_str("Lang1"),
Lang2 => f.write_str("Lang2"),
Lang3 => f.write_str("Lang3"),
Lang4 => f.write_str("Lang4"),
Lang5 => f.write_str("Lang5"),
NonConvert => f.write_str("NonConvert"),
Delete => f.write_str("Delete"),
End => f.write_str("End"),
Help => f.write_str("Help"),
Home => f.write_str("Home"),
Insert => f.write_str("Insert"),
PageDown => f.write_str("PageDown"),
PageUp => f.write_str("PageUp"),
ArrowDown => f.write_str("ArrowDown"),
ArrowLeft => f.write_str("ArrowLeft"),
ArrowRight => f.write_str("ArrowRight"),
ArrowUp => f.write_str("ArrowUp"),
NumLock => f.write_str("NumLock"),
Numpad0 => f.write_str("Numpad0"),
Numpad1 => f.write_str("Numpad1"),
Numpad2 => f.write_str("Numpad2"),
Numpad3 => f.write_str("Numpad3"),
Numpad4 => f.write_str("Numpad4"),
Numpad5 => f.write_str("Numpad5"),
Numpad6 => f.write_str("Numpad6"),
Numpad7 => f.write_str("Numpad7"),
Numpad8 => f.write_str("Numpad8"),
Numpad9 => f.write_str("Numpad9"),
NumpadAdd => f.write_str("NumpadAdd"),
NumpadBackspace => f.write_str("NumpadBackspace"),
NumpadClear => f.write_str("NumpadClear"),
NumpadClearEntry => f.write_str("NumpadClearEntry"),
NumpadComma => f.write_str("NumpadComma"),
NumpadDecimal => f.write_str("NumpadDecimal"),
NumpadDivide => f.write_str("NumpadDivide"),
NumpadEnter => f.write_str("NumpadEnter"),
NumpadEqual => f.write_str("NumpadEqual"),
NumpadHash => f.write_str("NumpadHash"),
NumpadMemoryAdd => f.write_str("NumpadMemoryAdd"),
NumpadMemoryClear => f.write_str("NumpadMemoryClear"),
NumpadMemoryRecall => f.write_str("NumpadMemoryRecall"),
NumpadMemoryStore => f.write_str("NumpadMemoryStore"),
NumpadMemorySubtract => f.write_str("NumpadMemorySubtract"),
NumpadMultiply => f.write_str("NumpadMultiply"),
NumpadParenLeft => f.write_str("NumpadParenLeft"),
NumpadParenRight => f.write_str("NumpadParenRight"),
NumpadStar => f.write_str("NumpadStar"),
NumpadSubtract => f.write_str("NumpadSubtract"),
Escape => f.write_str("Escape"),
Fn => f.write_str("Fn"),
FnLock => f.write_str("FnLock"),
PrintScreen => f.write_str("PrintScreen"),
ScrollLock => f.write_str("ScrollLock"),
Pause => f.write_str("Pause"),
BrowserBack => f.write_str("BrowserBack"),
BrowserFavorites => f.write_str("BrowserFavorites"),
BrowserForward => f.write_str("BrowserForward"),
BrowserHome => f.write_str("BrowserHome"),
BrowserRefresh => f.write_str("BrowserRefresh"),
BrowserSearch => f.write_str("BrowserSearch"),
BrowserStop => f.write_str("BrowserStop"),
Eject => f.write_str("Eject"),
LaunchApp1 => f.write_str("LaunchApp1"),
LaunchApp2 => f.write_str("LaunchApp2"),
LaunchMail => f.write_str("LaunchMail"),
MediaPlayPause => f.write_str("MediaPlayPause"),
MediaSelect => f.write_str("MediaSelect"),
MediaStop => f.write_str("MediaStop"),
MediaTrackNext => f.write_str("MediaTrackNext"),
MediaTrackPrevious => f.write_str("MediaTrackPrevious"),
Power => f.write_str("Power"),
Sleep => f.write_str("Sleep"),
AudioVolumeDown => f.write_str("AudioVolumeDown"),
AudioVolumeMute => f.write_str("AudioVolumeMute"),
AudioVolumeUp => f.write_str("AudioVolumeUp"),
WakeUp => f.write_str("WakeUp"),
Hyper => f.write_str("Hyper"),
Super => f.write_str("Super"),
Turbo => f.write_str("Turbo"),
Abort => f.write_str("Abort"),
Resume => f.write_str("Resume"),
Suspend => f.write_str("Suspend"),
Again => f.write_str("Again"),
Copy => f.write_str("Copy"),
Cut => f.write_str("Cut"),
Find => f.write_str("Find"),
Open => f.write_str("Open"),
Paste => f.write_str("Paste"),
Props => f.write_str("Props"),
Select => f.write_str("Select"),
Undo => f.write_str("Undo"),
Hiragana => f.write_str("Hiragana"),
Katakana => f.write_str("Katakana"),
Unidentified(v) => f.write_fmt(format_args!("Unidentified({v})")),
F1 => f.write_str("F1"),
F2 => f.write_str("F2"),
F3 => f.write_str("F3"),
F4 => f.write_str("F4"),
F5 => f.write_str("F5"),
F6 => f.write_str("F6"),
F7 => f.write_str("F7"),
F8 => f.write_str("F8"),
F9 => f.write_str("F9"),
F10 => f.write_str("F10"),
F11 => f.write_str("F11"),
F12 => f.write_str("F12"),
F13 => f.write_str("F13"),
F14 => f.write_str("F14"),
F15 => f.write_str("F15"),
F16 => f.write_str("F16"),
F17 => f.write_str("F17"),
F18 => f.write_str("F18"),
F19 => f.write_str("F19"),
F20 => f.write_str("F20"),
F21 => f.write_str("F21"),
F22 => f.write_str("F22"),
F23 => f.write_str("F23"),
F24 => f.write_str("F24"),
F25 => f.write_str("F25"),
F26 => f.write_str("F26"),
F27 => f.write_str("F27"),
F28 => f.write_str("F28"),
F29 => f.write_str("F29"),
F30 => f.write_str("F30"),
F31 => f.write_str("F31"),
F32 => f.write_str("F32"),
F33 => f.write_str("F33"),
F34 => f.write_str("F34"),
F35 => f.write_str("F35"),
BrightnessDown => f.write_str("BrightnessDown"),
BrightnessUp => f.write_str("BrightnessUp"),
DisplayToggleIntExt => f.write_str("DisplayToggleIntExt"),
KeyboardLayoutSelect => f.write_str("KeyboardLayoutSelect"),
LaunchAssistant => f.write_str("LaunchAssistant"),
LaunchControlPanel => f.write_str("LaunchControlPanel"),
LaunchScreenSaver => f.write_str("LaunchScreenSaver"),
MailForward => f.write_str("MailForward"),
MailReply => f.write_str("MailReply"),
MailSend => f.write_str("MailSend"),
MediaFastForward => f.write_str("MediaFastForward"),
MediaPause => f.write_str("MediaPause"),
MediaPlay => f.write_str("MediaPlay"),
MediaRecord => f.write_str("MediaRecord"),
MediaRewind => f.write_str("MediaRewind"),
MicrophoneMuteToggle => f.write_str("MicrophoneMuteToggle"),
PrivacyScreenToggle => f.write_str("PrivacyScreenToggle"),
SelectTask => f.write_str("SelectTask"),
ShowAllWindows => f.write_str("ShowAllWindows"),
ZoomToggle => f.write_str("ZoomToggle"),
}
}
}
impl FromStr for Code {
type Err = UnrecognizedCodeError;
fn from_str(s: &str) -> Result {
use Code::*;
match s {
"Backquote" => Ok(Backquote),
"Backslash" => Ok(Backslash),
"BracketLeft" => Ok(BracketLeft),
"BracketRight" => Ok(BracketRight),
"Comma" => Ok(Comma),
"Digit0" => Ok(Digit0),
"Digit1" => Ok(Digit1),
"Digit2" => Ok(Digit2),
"Digit3" => Ok(Digit3),
"Digit4" => Ok(Digit4),
"Digit5" => Ok(Digit5),
"Digit6" => Ok(Digit6),
"Digit7" => Ok(Digit7),
"Digit8" => Ok(Digit8),
"Digit9" => Ok(Digit9),
"Equal" => Ok(Equal),
"IntlBackslash" => Ok(IntlBackslash),
"IntlRo" => Ok(IntlRo),
"IntlYen" => Ok(IntlYen),
"KeyA" => Ok(KeyA),
"KeyB" => Ok(KeyB),
"KeyC" => Ok(KeyC),
"KeyD" => Ok(KeyD),
"KeyE" => Ok(KeyE),
"KeyF" => Ok(KeyF),
"KeyG" => Ok(KeyG),
"KeyH" => Ok(KeyH),
"KeyI" => Ok(KeyI),
"KeyJ" => Ok(KeyJ),
"KeyK" => Ok(KeyK),
"KeyL" => Ok(KeyL),
"KeyM" => Ok(KeyM),
"KeyN" => Ok(KeyN),
"KeyO" => Ok(KeyO),
"KeyP" => Ok(KeyP),
"KeyQ" => Ok(KeyQ),
"KeyR" => Ok(KeyR),
"KeyS" => Ok(KeyS),
"KeyT" => Ok(KeyT),
"KeyU" => Ok(KeyU),
"KeyV" => Ok(KeyV),
"KeyW" => Ok(KeyW),
"KeyX" => Ok(KeyX),
"KeyY" => Ok(KeyY),
"KeyZ" => Ok(KeyZ),
"Minus" => Ok(Minus),
"Period" => Ok(Period),
"Quote" => Ok(Quote),
"Semicolon" => Ok(Semicolon),
"Slash" => Ok(Slash),
"AltLeft" => Ok(AltLeft),
"AltRight" => Ok(AltRight),
"Backspace" => Ok(Backspace),
"CapsLock" => Ok(CapsLock),
"ContextMenu" => Ok(ContextMenu),
"ControlLeft" => Ok(ControlLeft),
"ControlRight" => Ok(ControlRight),
"Enter" => Ok(Enter),
"MetaLeft" | "OSLeft" => Ok(MetaLeft),
"MetaRight" | "OSRight" => Ok(MetaRight),
"ShiftLeft" => Ok(ShiftLeft),
"ShiftRight" => Ok(ShiftRight),
"Space" => Ok(Space),
"Tab" => Ok(Tab),
"Convert" => Ok(Convert),
"KanaMode" => Ok(KanaMode),
"Lang1" => Ok(Lang1),
"Lang2" => Ok(Lang2),
"Lang3" => Ok(Lang3),
"Lang4" => Ok(Lang4),
"Lang5" => Ok(Lang5),
"NonConvert" => Ok(NonConvert),
"Delete" => Ok(Delete),
"End" => Ok(End),
"Help" => Ok(Help),
"Home" => Ok(Home),
"Insert" => Ok(Insert),
"PageDown" => Ok(PageDown),
"PageUp" => Ok(PageUp),
"ArrowDown" => Ok(ArrowDown),
"ArrowLeft" => Ok(ArrowLeft),
"ArrowRight" => Ok(ArrowRight),
"ArrowUp" => Ok(ArrowUp),
"NumLock" => Ok(NumLock),
"Numpad0" => Ok(Numpad0),
"Numpad1" => Ok(Numpad1),
"Numpad2" => Ok(Numpad2),
"Numpad3" => Ok(Numpad3),
"Numpad4" => Ok(Numpad4),
"Numpad5" => Ok(Numpad5),
"Numpad6" => Ok(Numpad6),
"Numpad7" => Ok(Numpad7),
"Numpad8" => Ok(Numpad8),
"Numpad9" => Ok(Numpad9),
"NumpadAdd" => Ok(NumpadAdd),
"NumpadBackspace" => Ok(NumpadBackspace),
"NumpadClear" => Ok(NumpadClear),
"NumpadClearEntry" => Ok(NumpadClearEntry),
"NumpadComma" => Ok(NumpadComma),
"NumpadDecimal" => Ok(NumpadDecimal),
"NumpadDivide" => Ok(NumpadDivide),
"NumpadEnter" => Ok(NumpadEnter),
"NumpadEqual" => Ok(NumpadEqual),
"NumpadHash" => Ok(NumpadHash),
"NumpadMemoryAdd" => Ok(NumpadMemoryAdd),
"NumpadMemoryClear" => Ok(NumpadMemoryClear),
"NumpadMemoryRecall" => Ok(NumpadMemoryRecall),
"NumpadMemoryStore" => Ok(NumpadMemoryStore),
"NumpadMemorySubtract" => Ok(NumpadMemorySubtract),
"NumpadMultiply" => Ok(NumpadMultiply),
"NumpadParenLeft" => Ok(NumpadParenLeft),
"NumpadParenRight" => Ok(NumpadParenRight),
"NumpadStar" => Ok(NumpadStar),
"NumpadSubtract" => Ok(NumpadSubtract),
"Escape" => Ok(Escape),
"Fn" => Ok(Fn),
"FnLock" => Ok(FnLock),
"PrintScreen" => Ok(PrintScreen),
"ScrollLock" => Ok(ScrollLock),
"Pause" => Ok(Pause),
"BrowserBack" => Ok(BrowserBack),
"BrowserFavorites" => Ok(BrowserFavorites),
"BrowserForward" => Ok(BrowserForward),
"BrowserHome" => Ok(BrowserHome),
"BrowserRefresh" => Ok(BrowserRefresh),
"BrowserSearch" => Ok(BrowserSearch),
"BrowserStop" => Ok(BrowserStop),
"Eject" => Ok(Eject),
"LaunchApp1" => Ok(LaunchApp1),
"LaunchApp2" => Ok(LaunchApp2),
"LaunchMail" => Ok(LaunchMail),
"MediaPlayPause" => Ok(MediaPlayPause),
"MediaSelect" | "LaunchMediaPlayer" => Ok(MediaSelect),
"MediaStop" => Ok(MediaStop),
"MediaTrackNext" => Ok(MediaTrackNext),
"MediaTrackPrevious" => Ok(MediaTrackPrevious),
"Power" => Ok(Power),
"Sleep" => Ok(Sleep),
"AudioVolumeDown" | "VolumeDown" => Ok(AudioVolumeDown),
"AudioVolumeMute" | "VolumeMute" => Ok(AudioVolumeMute),
"AudioVolumeUp" | "VolumeUp" => Ok(AudioVolumeUp),
"WakeUp" => Ok(WakeUp),
"Hyper" => Ok(Hyper),
"Super" => Ok(Super),
"Turbo" => Ok(Turbo),
"Abort" => Ok(Abort),
"Resume" => Ok(Resume),
"Suspend" => Ok(Suspend),
"Again" => Ok(Again),
"Copy" => Ok(Copy),
"Cut" => Ok(Cut),
"Find" => Ok(Find),
"Open" => Ok(Open),
"Paste" => Ok(Paste),
"Props" => Ok(Props),
"Select" => Ok(Select),
"Undo" => Ok(Undo),
"Hiragana" => Ok(Hiragana),
"Katakana" => Ok(Katakana),
"Unidentified" => Ok(Unidentified(0)),
"F1" => Ok(F1),
"F2" => Ok(F2),
"F3" => Ok(F3),
"F4" => Ok(F4),
"F5" => Ok(F5),
"F6" => Ok(F6),
"F7" => Ok(F7),
"F8" => Ok(F8),
"F9" => Ok(F9),
"F10" => Ok(F10),
"F11" => Ok(F11),
"F12" => Ok(F12),
"F13" => Ok(F13),
"F14" => Ok(F14),
"F15" => Ok(F15),
"F16" => Ok(F16),
"F17" => Ok(F17),
"F18" => Ok(F18),
"F19" => Ok(F19),
"F20" => Ok(F20),
"F21" => Ok(F21),
"F22" => Ok(F22),
"F23" => Ok(F23),
"F24" => Ok(F24),
"F25" => Ok(F25),
"F26" => Ok(F26),
"F27" => Ok(F27),
"F28" => Ok(F28),
"F29" => Ok(F29),
"F30" => Ok(F30),
"F31" => Ok(F31),
"F32" => Ok(F32),
"F33" => Ok(F33),
"F34" => Ok(F34),
"F35" => Ok(F35),
"BrightnessDown" => Ok(BrightnessDown),
"BrightnessUp" => Ok(BrightnessUp),
"DisplayToggleIntExt" => Ok(DisplayToggleIntExt),
"KeyboardLayoutSelect" => Ok(KeyboardLayoutSelect),
"LaunchAssistant" => Ok(LaunchAssistant),
"LaunchControlPanel" => Ok(LaunchControlPanel),
"LaunchScreenSaver" => Ok(LaunchScreenSaver),
"MailForward" => Ok(MailForward),
"MailReply" => Ok(MailReply),
"MailSend" => Ok(MailSend),
"MediaFastForward" => Ok(MediaFastForward),
"MediaPause" => Ok(MediaPause),
"MediaPlay" => Ok(MediaPlay),
"MediaRecord" => Ok(MediaRecord),
"MediaRewind" => Ok(MediaRewind),
"MicrophoneMuteToggle" => Ok(MicrophoneMuteToggle),
"PrivacyScreenToggle" => Ok(PrivacyScreenToggle),
"SelectTask" => Ok(SelectTask),
"ShowAllWindows" => Ok(ShowAllWindows),
"ZoomToggle" => Ok(ZoomToggle),
_ => Err(UnrecognizedCodeError),
}
}
}
/// Parse from string error, returned when string does not match to any Code variant.
#[derive(Clone, Debug)]
pub struct UnrecognizedCodeError;
impl fmt::Display for UnrecognizedCodeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Unrecognized code")
}
}
impl Error for UnrecognizedCodeError {}
impl Default for Code {
fn default() -> Code {
Code::Unidentified(0)
}
}