keyboard_types/
key.rs

1
2// AUTO GENERATED CODE - DO NOT EDIT
3#![cfg_attr(rustfmt, rustfmt_skip)]
4
5use std::fmt::{self, Display};
6use std::str::FromStr;
7use std::error::Error;
8
9/// Key represents the meaning of a keypress.
10///
11/// Specification:
12/// <https://w3c.github.io/uievents-key/>
13#[derive(Clone, Debug, Eq, PartialEq, Hash)]
14#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
15#[non_exhaustive]
16pub enum Key {
17    /// A key string that corresponds to the character typed by the user,
18    /// taking into account the user’s current locale setting, modifier state,
19    /// and any system-level keyboard mapping overrides that are in effect.
20    Character(String),
21    
22    /// This key value is used when an implementation is unable to
23    /// identify another key value, due to either hardware,
24    /// platform, or software constraints.
25    Unidentified,
26    /// The <code class="keycap">Alt</code> (Alternative) key.<br> This key enables the alternate modifier function for interpreting concurrent or subsequent keyboard input.<br> This key value is also used for the Apple <code class="keycap">Option</code> key.
27    Alt,
28    /// The Alternate Graphics (<code class="keycap">AltGr</code> or <code class="keycap">AltGraph</code>) key.
29    /// This key is used enable the ISO Level 3 shift modifier (the standard <code class="keycap">Shift</code> key is the level 2 modifier).
30    /// See [ISO9995-1].
31    AltGraph,
32    /// The <code class="keycap">Caps Lock</code> (Capital) key.
33    /// Toggle capital character lock function for interpreting subsequent keyboard input event.
34    CapsLock,
35    /// The <code class="keycap">Control</code> or <code class="keycap">Ctrl</code> key, to enable control modifier function for interpreting concurrent or subsequent keyboard input.
36    Control,
37    /// The Function switch <code class="keycap">Fn</code> key.<br> Activating this key simultaneously with another key changes that key’s value to an alternate character or function.
38    /// This key is often handled directly in the keyboard hardware and does not usually generate key events.
39    Fn,
40    /// The Function-Lock (<code class="keycap">FnLock</code> or <code class="keycap">F-Lock</code>) key.
41    /// Activating this key switches the mode of the keyboard to changes some keys' values to an alternate character or function.
42    /// This key is often handled directly in the keyboard hardware and does not usually generate key events.
43    FnLock,
44    /// The <code class="keycap">Meta</code> key, to enable meta modifier function for interpreting concurrent or subsequent keyboard input.
45    /// This key value is used for the <q>Windows Logo</q> key and the Apple <code class="keycap">Command</code> or <code class="keycap">⌘</code> key.
46    Meta,
47    /// The <code class="keycap">NumLock</code> or Number Lock key, to toggle numpad mode function for interpreting subsequent keyboard input.
48    NumLock,
49    /// The <code class="keycap">Scroll Lock</code> key, to toggle between scrolling and cursor movement modes.
50    ScrollLock,
51    /// The <code class="keycap">Shift</code> key, to enable shift modifier function for interpreting concurrent or subsequent keyboard input.
52    Shift,
53    /// The Symbol modifier key (used on some virtual keyboards).
54    Symbol,
55    /// The Symbol Lock key.
56    SymbolLock,
57    /// The <code class="keycap">Hyper</code> key.
58    Hyper,
59    /// The <code class="keycap">Super</code> key.
60    Super,
61    /// The <code class="keycap">Enter</code> or <code class="keycap">↵</code> key, to activate current selection or accept current input.<br> This key value is also used for the <code class="keycap">Return</code> (Macintosh numpad) key.<br> This key value is also used for the Android <code class="android">KEYCODE_DPAD_CENTER</code>.
62    Enter,
63    /// The Horizontal Tabulation <code class="keycap">Tab</code> key.
64    Tab,
65    /// The down arrow key, to navigate or traverse downward. (<code class="android">KEYCODE_DPAD_DOWN</code>)
66    ArrowDown,
67    /// The left arrow key, to navigate or traverse leftward. (<code class="android">KEYCODE_DPAD_LEFT</code>)
68    ArrowLeft,
69    /// The right arrow key, to navigate or traverse rightward. (<code class="android">KEYCODE_DPAD_RIGHT</code>)
70    ArrowRight,
71    /// The up arrow key, to navigate or traverse upward. (<code class="android">KEYCODE_DPAD_UP</code>)
72    ArrowUp,
73    /// The End key, used with keyboard entry to go to the end of content (<code class="android">KEYCODE_MOVE_END</code>).
74    End,
75    /// The Home key, used with keyboard entry, to go to start of content (<code class="android">KEYCODE_MOVE_HOME</code>).<br> For the mobile phone <code class="keycap">Home</code> key (which goes to the phone’s main screen), use <code class="key">"GoHome"</code>.
76    Home,
77    /// The Page Down key, to scroll down or display next page of content.
78    PageDown,
79    /// The Page Up key, to scroll up or display previous page of content.
80    PageUp,
81    /// The Backspace key. This key value is also used for the key labeled <code class="keycap">Delete</code> on MacOS keyboards.
82    Backspace,
83    /// Remove the currently selected input.
84    Clear,
85    /// Copy the current selection. (<code class="appcommand">APPCOMMAND_COPY</code>)
86    Copy,
87    /// The Cursor Select (Crsel) key.
88    CrSel,
89    /// Cut the current selection. (<code class="appcommand">APPCOMMAND_CUT</code>)
90    Cut,
91    /// The Delete (Del) Key.
92    /// This key value is also used for the key labeled <code class="keycap">Delete</code> on MacOS keyboards when modified by the <code class="keycap">Fn</code> key.
93    Delete,
94    /// The Erase to End of Field key.
95    /// This key deletes all characters from the current cursor position to the end of the current field.
96    EraseEof,
97    /// The Extend Selection (Exsel) key.
98    ExSel,
99    /// The Insert (Ins) key, to toggle between text modes for insertion or overtyping. (<code class="android">KEYCODE_INSERT</code>)
100    Insert,
101    /// The Paste key. (<code class="appcommand">APPCOMMAND_PASTE</code>)
102    Paste,
103    /// Redo the last action. (<code class="appcommand">APPCOMMAND_REDO</code>)
104    Redo,
105    /// Undo the last action. (<code class="appcommand">APPCOMMAND_UNDO</code>)
106    Undo,
107    /// The Accept (Commit, OK) key. Accept current option or input method sequence conversion.
108    Accept,
109    /// The Again key, to redo or repeat an action.
110    Again,
111    /// The Attention (Attn) key.
112    Attn,
113    /// The Cancel key.
114    Cancel,
115    /// Show the application’s context menu.
116    /// This key is commonly found between the right <code class="keycap">Meta</code> key and the right <code class="keycap">Control</code> key.
117    ContextMenu,
118    /// The <code class="keycap">Esc</code> key. This key was originally used to initiate an escape sequence, but is
119    /// now more generally used to exit or "escape" the current context, such as closing a dialog
120    /// or exiting full screen mode.
121    Escape,
122    /// The Execute key.
123    Execute,
124    /// Open the Find dialog. (<code class="appcommand">APPCOMMAND_FIND</code>)
125    Find,
126    /// Open a help dialog or toggle display of help information. (<code class="appcommand"><code class="appcommand">APPCOMMAND_HELP</code></code>, <code class="android"><code class="android">KEYCODE_HELP</code></code>)
127    Help,
128    /// Pause the current state or application (as appropriate).
129    /// <p class="note" role="note">Do not use this value for the <code class="keycap">Pause</code> button on media controllers. Use <code class="key">"MediaPause"</code> instead.</p>
130    Pause,
131    /// Play or resume the current state or application (as appropriate).
132    /// <p class="note" role="note">Do not use this value for the <code class="keycap">Play</code> button on media controllers. Use <code class="key">"MediaPlay"</code> instead.</p>
133    Play,
134    /// The properties (Props) key.
135    Props,
136    /// The Select key.
137    Select,
138    /// The ZoomIn key. (<code class="android">KEYCODE_ZOOM_IN</code>)
139    ZoomIn,
140    /// The ZoomOut key. (<code class="android">KEYCODE_ZOOM_OUT</code>)
141    ZoomOut,
142    /// The Brightness Down key. Typically controls the display brightness. (<code class="android">KEYCODE_BRIGHTNESS_DOWN</code>)
143    BrightnessDown,
144    /// The Brightness Up key. Typically controls the display brightness. (<code class="android">KEYCODE_BRIGHTNESS_UP</code>)
145    BrightnessUp,
146    /// Toggle removable media to eject (open) and insert (close) state. (<code class="android">KEYCODE_MEDIA_EJECT</code>)
147    Eject,
148    /// The LogOff key.
149    LogOff,
150    /// Toggle power state. (<code class="android">KEYCODE_POWER</code>)
151    /// <p class="note" role="note">Note: Some devices might not expose this key to the operating environment.</p>
152    Power,
153    /// The <code class="keycap">PowerOff</code> key. Sometime called <code class="keycap">PowerDown</code>.
154    PowerOff,
155    /// The <code class="keycap">Print Screen</code> or <code class="keycap">SnapShot</code> key, to initiate print-screen function.
156    PrintScreen,
157    /// The Hibernate key.
158    /// This key saves the current state of the computer to disk so that it can be restored. The computer will then shutdown.
159    Hibernate,
160    /// The Standby key.
161    /// This key turns off the display and places the computer into a low-power mode without completely shutting down.
162    /// It is sometimes labelled <code class="keycap">Suspend</code> or <code class="keycap">Sleep</code> key. (<code class="android"><code class="android">KEYCODE_SLEEP</code></code>)
163    Standby,
164    /// The WakeUp key. (<code class="android">KEYCODE_WAKEUP</code>)
165    WakeUp,
166    /// The All Candidates key, to initate the multi-candidate mode.
167    AllCandidates,
168    /// The Alphanumeric key.
169    Alphanumeric,
170    /// The Code Input key, to initiate the Code Input mode to allow characters to be entered by their code points.
171    CodeInput,
172    /// The Compose key, also known as <em>Multi_key</em> on the X Window System.
173    /// This key acts in a manner similar to a
174    /// dead key, triggering a mode where subsequent key presses are combined to produce a different character.
175    Compose,
176    /// The Convert key, to convert the current input method sequence.
177    Convert,
178    /// A dead key combining key. It may be any combining key from any keyboard layout. For example, on a
179    /// PC/AT French keyboard, using a French mapping and without any modifier activiated, this is the key value <code class="unicode">U+0302</code> COMBINING CIRCUMFLEX ACCENT. In another layout this might be a different unicode combining key.<br> For applications that need to differentiate between specific combining characters, the associated compositionupdate event’s data attribute provides the specific key value.
180    Dead,
181    /// The Final Mode <code class="keycap">Final</code> key used on some Asian keyboards, to enable the final mode for IMEs.
182    FinalMode,
183    /// Switch to the first character group. (ISO/IEC 9995)
184    GroupFirst,
185    /// Switch to the last character group. (ISO/IEC 9995)
186    GroupLast,
187    /// Switch to the next character group. (ISO/IEC 9995)
188    GroupNext,
189    /// Switch to the previous character group. (ISO/IEC 9995)
190    GroupPrevious,
191    /// The Mode Change key, to toggle between or cycle through input modes of IMEs.
192    ModeChange,
193    /// The Next Candidate function key.
194    NextCandidate,
195    /// The NonConvert ("Don’t Convert") key, to accept current input method sequence without conversion in IMEs.
196    NonConvert,
197    /// The Previous Candidate function key.
198    PreviousCandidate,
199    /// The Process key.
200    Process,
201    /// The Single Candidate function key.
202    SingleCandidate,
203    /// The Hangul (Korean characters) Mode key, to toggle between Hangul and English modes.
204    HangulMode,
205    /// The Hanja (Korean characters) Mode key.
206    HanjaMode,
207    /// The Junja (Korean characters) Mode key.
208    JunjaMode,
209    /// The Eisu key. This key may close the IME, but its purpose
210    /// is defined by the current IME. (<code class="android">KEYCODE_EISU</code>)
211    Eisu,
212    /// The (Half-Width) Characters key.
213    Hankaku,
214    /// The Hiragana (Japanese Kana characters) key.
215    Hiragana,
216    /// The Hiragana/Katakana toggle key. (<code class="android">KEYCODE_KATAKANA_HIRAGANA</code>)
217    HiraganaKatakana,
218    /// The Kana Mode (Kana Lock) key. This key is used to enter
219    /// hiragana mode (typically from romaji mode).
220    KanaMode,
221    /// The Kanji (Japanese name for ideographic characters of Chinese origin) Mode key.
222    /// This key is typically used to switch to a hiragana keyboard for
223    /// the purpose of converting input into kanji. (<code class="android">KEYCODE_KANA</code>)
224    KanjiMode,
225    /// The Katakana (Japanese Kana characters) key.
226    Katakana,
227    /// The Roman characters function key.
228    Romaji,
229    /// The Zenkaku (Full-Width) Characters key.
230    Zenkaku,
231    /// The Zenkaku/Hankaku (full-width/half-width) toggle key. (<code class="android">KEYCODE_ZENKAKU_HANKAKU</code>)
232    ZenkakuHankaku,
233    /// General purpose virtual function key, as index 1.
234    Soft1,
235    /// General purpose virtual function key, as index 2.
236    Soft2,
237    /// General purpose virtual function key, as index 3.
238    Soft3,
239    /// General purpose virtual function key, as index 4.
240    Soft4,
241    /// Select next (numerically or logically) lower channel. (<code class="appcommand"><code class="appcommand">APPCOMMAND_MEDIA_CHANNEL_DOWN</code></code>, <code class="android"><code class="android">KEYCODE_CHANNEL_DOWN</code></code>)
242    ChannelDown,
243    /// Select next (numerically or logically) higher channel. (<code class="appcommand"><code class="appcommand">APPCOMMAND_MEDIA_CHANNEL_UP</code></code>, <code class="android"><code class="android">KEYCODE_CHANNEL_UP</code></code>)
244    ChannelUp,
245    /// Close the current document or message (Note: This doesn’t close the application). (<code class="appcommand">APPCOMMAND_CLOSE</code>)
246    Close,
247    /// Open an editor to forward the current message. (<code class="appcommand">APPCOMMAND_FORWARD_MAIL</code>)
248    MailForward,
249    /// Open an editor to reply to the current message. (<code class="appcommand">APPCOMMAND_REPLY_TO_MAIL</code>)
250    MailReply,
251    /// Send the current message. (<code class="appcommand">APPCOMMAND_SEND_MAIL</code>)
252    MailSend,
253    /// Close the current media, for example to close a CD or DVD tray. (<code class="android">KEYCODE_MEDIA_CLOSE</code>)
254    MediaClose,
255    /// Initiate or continue forward playback at faster than normal speed, or increase speed if already fast forwarding. (<code class="appcommand"><code class="appcommand">APPCOMMAND_MEDIA_FAST_FORWARD</code></code>, <code class="android"><code class="android">KEYCODE_MEDIA_FAST_FORWARD</code></code>)
256    MediaFastForward,
257    /// Pause the currently playing media. (<code class="appcommand"><code class="appcommand">APPCOMMAND_MEDIA_PAUSE</code></code>, <code class="android"><code class="android">KEYCODE_MEDIA_PAUSE</code></code>)
258    /// <p class="note" role="note">Media controller devices should use this value rather than <code class="key">"Pause"</code> for their pause keys.</p>
259    MediaPause,
260    /// Initiate or continue media playback at normal speed, if not currently playing at normal speed. (<code class="appcommand"><code class="appcommand">APPCOMMAND_MEDIA_PLAY</code></code>, <code class="android"><code class="android">KEYCODE_MEDIA_PLAY</code></code>)
261    MediaPlay,
262    /// Toggle media between play and pause states. (<code class="appcommand"><code class="appcommand">APPCOMMAND_MEDIA_PLAY_PAUSE</code></code>, <code class="android"><code class="android">KEYCODE_MEDIA_PLAY_PAUSE</code></code>)
263    MediaPlayPause,
264    /// Initiate or resume recording of currently selected media. (<code class="appcommand"><code class="appcommand">APPCOMMAND_MEDIA_RECORD</code></code>, <code class="android"><code class="android">KEYCODE_MEDIA_RECORD</code></code>)
265    MediaRecord,
266    /// Initiate or continue reverse playback at faster than normal speed, or increase speed if already rewinding. (<code class="appcommand"><code class="appcommand">APPCOMMAND_MEDIA_REWIND</code></code>, <code class="android"><code class="android">KEYCODE_MEDIA_REWIND</code></code>)
267    MediaRewind,
268    /// Stop media playing, pausing, forwarding, rewinding, or recording, if not already stopped. (<code class="appcommand"><code class="appcommand">APPCOMMAND_MEDIA_STOP</code></code>, <code class="android"><code class="android">KEYCODE_MEDIA_STOP</code></code>)
269    MediaStop,
270    /// Seek to next media or program track. (<code class="appcommand"><code class="appcommand">APPCOMMAND_MEDIA_NEXTTRACK</code></code>, <code class="android"><code class="android">KEYCODE_MEDIA_NEXT</code></code>)
271    MediaTrackNext,
272    /// Seek to previous media or program track. (<code class="appcommand"><code class="appcommand">APPCOMMAND_MEDIA_PREVIOUSTRACK</code></code>, <code class="android"><code class="android">KEYCODE_MEDIA_PREVIOUS</code></code>)
273    MediaTrackPrevious,
274    /// Open a new document or message. (<code class="appcommand">APPCOMMAND_NEW</code>)
275    New,
276    /// Open an existing document or message. (<code class="appcommand">APPCOMMAND_OPEN</code>)
277    Open,
278    /// Print the current document or message. (<code class="appcommand">APPCOMMAND_PRINT</code>)
279    Print,
280    /// Save the current document or message. (<code class="appcommand">APPCOMMAND_SAVE</code>)
281    Save,
282    /// Spellcheck the current document or selection. (<code class="appcommand">APPCOMMAND_SPELL_CHECK</code>)
283    SpellCheck,
284    /// The <code class="keycap">11</code> key found on media numpads that
285    /// have buttons from <code class="keycap">1</code> ... <code class="keycap">12</code>.
286    Key11,
287    /// The <code class="keycap">12</code> key found on media numpads that
288    /// have buttons from <code class="keycap">1</code> ... <code class="keycap">12</code>.
289    Key12,
290    /// Adjust audio balance leftward. (<code class="vk">VK_AUDIO_BALANCE_LEFT</code>)
291    AudioBalanceLeft,
292    /// Adjust audio balance rightward. (<code class="vk">VK_AUDIO_BALANCE_RIGHT</code>)
293    AudioBalanceRight,
294    /// Decrease audio bass boost or cycle down through bass boost states. (<code class="appcommand"><code class="appcommand">APPCOMMAND_BASS_DOWN</code></code>, <code class="vk"><code class="vk">VK_BASS_BOOST_DOWN</code></code>)
295    AudioBassBoostDown,
296    /// Toggle bass boost on/off. (<code class="appcommand">APPCOMMAND_BASS_BOOST</code>)
297    AudioBassBoostToggle,
298    /// Increase audio bass boost or cycle up through bass boost states. (<code class="appcommand"><code class="appcommand">APPCOMMAND_BASS_UP</code></code>, <code class="vk"><code class="vk">VK_BASS_BOOST_UP</code></code>)
299    AudioBassBoostUp,
300    /// Adjust audio fader towards front. (<code class="vk">VK_FADER_FRONT</code>)
301    AudioFaderFront,
302    /// Adjust audio fader towards rear. (<code class="vk">VK_FADER_REAR</code>)
303    AudioFaderRear,
304    /// Advance surround audio mode to next available mode. (<code class="vk">VK_SURROUND_MODE_NEXT</code>)
305    AudioSurroundModeNext,
306    /// Decrease treble. (<code class="appcommand">APPCOMMAND_TREBLE_DOWN</code>)
307    AudioTrebleDown,
308    /// Increase treble. (<code class="appcommand">APPCOMMAND_TREBLE_UP</code>)
309    AudioTrebleUp,
310    /// Decrease audio volume. (<code class="appcommand"><code class="appcommand">APPCOMMAND_VOLUME_DOWN</code></code>, <code class="android"><code class="android">KEYCODE_VOLUME_DOWN</code></code>)
311    AudioVolumeDown,
312    /// Increase audio volume. (<code class="appcommand"><code class="appcommand">APPCOMMAND_VOLUME_UP</code></code>, <code class="android"><code class="android">KEYCODE_VOLUME_UP</code></code>)
313    AudioVolumeUp,
314    /// Toggle between muted state and prior volume level. (<code class="appcommand"><code class="appcommand">APPCOMMAND_VOLUME_MUTE</code></code>, <code class="android"><code class="android">KEYCODE_VOLUME_MUTE</code></code>)
315    AudioVolumeMute,
316    /// Toggle the microphone on/off. (<code class="appcommand">APPCOMMAND_MIC_ON_OFF_TOGGLE</code>)
317    MicrophoneToggle,
318    /// Decrease microphone volume. (<code class="appcommand">APPCOMMAND_MICROPHONE_VOLUME_DOWN</code>)
319    MicrophoneVolumeDown,
320    /// Increase microphone volume. (<code class="appcommand">APPCOMMAND_MICROPHONE_VOLUME_UP</code>)
321    MicrophoneVolumeUp,
322    /// Mute the microphone. (<code class="appcommand"><code class="appcommand">APPCOMMAND_MICROPHONE_VOLUME_MUTE</code></code>, <code class="android"><code class="android">KEYCODE_MUTE</code></code>)
323    MicrophoneVolumeMute,
324    /// Show correction list when a word is incorrectly identified. (<code class="appcommand">APPCOMMAND_CORRECTION_LIST</code>)
325    SpeechCorrectionList,
326    /// Toggle between dictation mode and command/control mode. (<code class="appcommand">APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE</code>)
327    SpeechInputToggle,
328    /// The first generic "LaunchApplication" key. This is commonly associated with launching "My Computer", and may have a computer symbol on the key. (<code class="appcommand">APPCOMMAND_LAUNCH_APP1</code>)
329    LaunchApplication1,
330    /// The second generic "LaunchApplication" key. This is commonly associated with launching "Calculator", and may have a calculator symbol on the key. (<code class="appcommand"><code class="appcommand">APPCOMMAND_LAUNCH_APP2</code></code>, <code class="android"><code class="android">KEYCODE_CALCULATOR</code></code>)
331    LaunchApplication2,
332    /// The "Calendar" key. (<code class="android">KEYCODE_CALENDAR</code>)
333    LaunchCalendar,
334    /// The "Contacts" key. (<code class="android">KEYCODE_CONTACTS</code>)
335    LaunchContacts,
336    /// The "Mail" key. (<code class="appcommand">APPCOMMAND_LAUNCH_MAIL</code>)
337    LaunchMail,
338    /// The "Media Player" key. (<code class="appcommand">APPCOMMAND_LAUNCH_MEDIA_SELECT</code>)
339    LaunchMediaPlayer,
340    /// The "Music Player" key.
341    LaunchMusicPlayer,
342    /// The "Phone" key.
343    LaunchPhone,
344    /// The "Screen Saver" key.
345    LaunchScreenSaver,
346    /// The "Spreadsheet" key.
347    LaunchSpreadsheet,
348    /// The "Web Browser" key.
349    LaunchWebBrowser,
350    /// The "WebCam" key.
351    LaunchWebCam,
352    /// The "Word Processor" key.
353    LaunchWordProcessor,
354    /// Navigate to previous content or page in current history. (<code class="appcommand">APPCOMMAND_BROWSER_BACKWARD</code>)
355    BrowserBack,
356    /// Open the list of browser favorites. (<code class="appcommand">APPCOMMAND_BROWSER_FAVORITES</code>)
357    BrowserFavorites,
358    /// Navigate to next content or page in current history. (<code class="appcommand">APPCOMMAND_BROWSER_FORWARD</code>)
359    BrowserForward,
360    /// Go to the user’s preferred home page. (<code class="appcommand">APPCOMMAND_BROWSER_HOME</code>)
361    BrowserHome,
362    /// Refresh the current page or content. (<code class="appcommand">APPCOMMAND_BROWSER_REFRESH</code>)
363    BrowserRefresh,
364    /// Call up the user’s preferred search page. (<code class="appcommand">APPCOMMAND_BROWSER_SEARCH</code>)
365    BrowserSearch,
366    /// Stop loading the current page or content. (<code class="appcommand">APPCOMMAND_BROWSER_STOP</code>)
367    BrowserStop,
368    /// The Application switch key, which provides a list of recent apps to switch between. (<code class="android">KEYCODE_APP_SWITCH</code>)
369    AppSwitch,
370    /// The Call key. (<code class="android">KEYCODE_CALL</code>)
371    Call,
372    /// The Camera key. (<code class="android">KEYCODE_CAMERA</code>)
373    Camera,
374    /// The Camera focus key. (<code class="android">KEYCODE_FOCUS</code>)
375    CameraFocus,
376    /// The End Call key. (<code class="android">KEYCODE_ENDCALL</code>)
377    EndCall,
378    /// The Back key. (<code class="android">KEYCODE_BACK</code>)
379    GoBack,
380    /// The Home key, which goes to the phone’s main screen. (<code class="android">KEYCODE_HOME</code>)
381    GoHome,
382    /// The Headset Hook key. (<code class="android">KEYCODE_HEADSETHOOK</code>)
383    HeadsetHook,
384    /// The Last Number Redial key.
385    LastNumberRedial,
386    /// The Notification key. (<code class="android">KEYCODE_NOTIFICATION</code>)
387    Notification,
388    /// Toggle between manner mode state: silent, vibrate, ring, ... (<code class="android">KEYCODE_MANNER_MODE</code>)
389    MannerMode,
390    /// The Voice Dial key.
391    VoiceDial,
392    /// Switch to viewing TV. (<code class="android">KEYCODE_TV</code>)
393    TV,
394    /// TV 3D Mode. (<code class="android">KEYCODE_3D_MODE</code>)
395    TV3DMode,
396    /// Toggle between antenna and cable input. (<code class="android">KEYCODE_TV_ANTENNA_CABLE</code>)
397    TVAntennaCable,
398    /// Audio description. (<code class="android">KEYCODE_TV_AUDIO_DESCRIPTION</code>)
399    TVAudioDescription,
400    /// Audio description mixing volume down. (<code class="android">KEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN</code>)
401    TVAudioDescriptionMixDown,
402    /// Audio description mixing volume up. (<code class="android">KEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP</code>)
403    TVAudioDescriptionMixUp,
404    /// Contents menu. (<code class="android">KEYCODE_TV_CONTENTS_MENU</code>)
405    TVContentsMenu,
406    /// Contents menu. (<code class="android">KEYCODE_TV_DATA_SERVICE</code>)
407    TVDataService,
408    /// Switch the input mode on an external TV. (<code class="android">KEYCODE_TV_INPUT</code>)
409    TVInput,
410    /// Switch to component input #1. (<code class="android">KEYCODE_TV_INPUT_COMPONENT_1</code>)
411    TVInputComponent1,
412    /// Switch to component input #2. (<code class="android">KEYCODE_TV_INPUT_COMPONENT_2</code>)
413    TVInputComponent2,
414    /// Switch to composite input #1. (<code class="android">KEYCODE_TV_INPUT_COMPOSITE_1</code>)
415    TVInputComposite1,
416    /// Switch to composite input #2. (<code class="android">KEYCODE_TV_INPUT_COMPOSITE_2</code>)
417    TVInputComposite2,
418    /// Switch to HDMI input #1. (<code class="android">KEYCODE_TV_INPUT_HDMI_1</code>)
419    TVInputHDMI1,
420    /// Switch to HDMI input #2. (<code class="android">KEYCODE_TV_INPUT_HDMI_2</code>)
421    TVInputHDMI2,
422    /// Switch to HDMI input #3. (<code class="android">KEYCODE_TV_INPUT_HDMI_3</code>)
423    TVInputHDMI3,
424    /// Switch to HDMI input #4. (<code class="android">KEYCODE_TV_INPUT_HDMI_4</code>)
425    TVInputHDMI4,
426    /// Switch to VGA input #1. (<code class="android">KEYCODE_TV_INPUT_VGA_1</code>)
427    TVInputVGA1,
428    /// Media context menu. (<code class="android">KEYCODE_TV_MEDIA_CONTEXT_MENU</code>)
429    TVMediaContext,
430    /// Toggle network. (<code class="android">KEYCODE_TV_NETWORK</code>)
431    TVNetwork,
432    /// Number entry. (<code class="android">KEYCODE_TV_NUMBER_ENTRY</code>)
433    TVNumberEntry,
434    /// Toggle the power on an external TV. (<code class="android">KEYCODE_TV_POWER</code>)
435    TVPower,
436    /// Radio. (<code class="android">KEYCODE_TV_RADIO_SERVICE</code>)
437    TVRadioService,
438    /// Satellite. (<code class="android">KEYCODE_TV_SATELLITE</code>)
439    TVSatellite,
440    /// Broadcast Satellite. (<code class="android">KEYCODE_TV_SATELLITE_BS</code>)
441    TVSatelliteBS,
442    /// Communication Satellite. (<code class="android">KEYCODE_TV_SATELLITE_CS</code>)
443    TVSatelliteCS,
444    /// Toggle between available satellites. (<code class="android">KEYCODE_TV_SATELLITE_SERVICE</code>)
445    TVSatelliteToggle,
446    /// Analog Terrestrial. (<code class="android">KEYCODE_TV_TERRESTRIAL_ANALOG</code>)
447    TVTerrestrialAnalog,
448    /// Digital Terrestrial. (<code class="android">KEYCODE_TV_TERRESTRIAL_DIGITAL</code>)
449    TVTerrestrialDigital,
450    /// Timer programming. (<code class="android">KEYCODE_TV_TIMER_PROGRAMMING</code>)
451    TVTimer,
452    /// Switch the input mode on an external AVR (audio/video receiver). (<code class="android">KEYCODE_AVR_INPUT</code>)
453    AVRInput,
454    /// Toggle the power on an external AVR (audio/video receiver). (<code class="android">KEYCODE_AVR_POWER</code>)
455    AVRPower,
456    /// General purpose color-coded media function key, as index 0 (red). (<code class="vk"><code class="vk">VK_COLORED_KEY_0</code></code>, <code class="android"><code class="android">KEYCODE_PROG_RED</code></code>)
457    ColorF0Red,
458    /// General purpose color-coded media function key, as index 1 (green). (<code class="vk"><code class="vk">VK_COLORED_KEY_1</code></code>, <code class="android"><code class="android">KEYCODE_PROG_GREEN</code></code>)
459    ColorF1Green,
460    /// General purpose color-coded media function key, as index 2 (yellow). (<code class="vk"><code class="vk">VK_COLORED_KEY_2</code></code>, <code class="android"><code class="android">KEYCODE_PROG_YELLOW</code></code>)
461    ColorF2Yellow,
462    /// General purpose color-coded media function key, as index 3 (blue). (<code class="vk"><code class="vk">VK_COLORED_KEY_3</code></code>, <code class="android"><code class="android">KEYCODE_PROG_BLUE</code></code>)
463    ColorF3Blue,
464    /// General purpose color-coded media function key, as index 4 (grey). (<code class="vk">VK_COLORED_KEY_4</code>)
465    ColorF4Grey,
466    /// General purpose color-coded media function key, as index 5 (brown). (<code class="vk">VK_COLORED_KEY_5</code>)
467    ColorF5Brown,
468    /// Toggle the display of Closed Captions. (<code class="vk"><code class="vk">VK_CC</code></code>, <code class="android"><code class="android">KEYCODE_CAPTIONS</code></code>)
469    ClosedCaptionToggle,
470    /// Adjust brightness of device, by toggling between or cycling through states. (<code class="vk">VK_DIMMER</code>)
471    Dimmer,
472    /// Swap video sources. (<code class="vk">VK_DISPLAY_SWAP</code>)
473    DisplaySwap,
474    /// Select Digital Video Rrecorder. (<code class="android">KEYCODE_DVR</code>)
475    DVR,
476    /// Exit the current application. (<code class="vk">VK_EXIT</code>)
477    Exit,
478    /// Clear program or content stored as favorite 0. (<code class="vk">VK_CLEAR_FAVORITE_0</code>)
479    FavoriteClear0,
480    /// Clear program or content stored as favorite 1. (<code class="vk">VK_CLEAR_FAVORITE_1</code>)
481    FavoriteClear1,
482    /// Clear program or content stored as favorite 2. (<code class="vk">VK_CLEAR_FAVORITE_2</code>)
483    FavoriteClear2,
484    /// Clear program or content stored as favorite 3. (<code class="vk">VK_CLEAR_FAVORITE_3</code>)
485    FavoriteClear3,
486    /// Select (recall) program or content stored as favorite 0. (<code class="vk">VK_RECALL_FAVORITE_0</code>)
487    FavoriteRecall0,
488    /// Select (recall) program or content stored as favorite 1. (<code class="vk">VK_RECALL_FAVORITE_1</code>)
489    FavoriteRecall1,
490    /// Select (recall) program or content stored as favorite 2. (<code class="vk">VK_RECALL_FAVORITE_2</code>)
491    FavoriteRecall2,
492    /// Select (recall) program or content stored as favorite 3. (<code class="vk">VK_RECALL_FAVORITE_3</code>)
493    FavoriteRecall3,
494    /// Store current program or content as favorite 0. (<code class="vk">VK_STORE_FAVORITE_0</code>)
495    FavoriteStore0,
496    /// Store current program or content as favorite 1. (<code class="vk">VK_STORE_FAVORITE_1</code>)
497    FavoriteStore1,
498    /// Store current program or content as favorite 2. (<code class="vk">VK_STORE_FAVORITE_2</code>)
499    FavoriteStore2,
500    /// Store current program or content as favorite 3. (<code class="vk">VK_STORE_FAVORITE_3</code>)
501    FavoriteStore3,
502    /// Toggle display of program or content guide. (<code class="vk"><code class="vk">VK_GUIDE</code></code>, <code class="android"><code class="android">KEYCODE_GUIDE</code></code>)
503    Guide,
504    /// If guide is active and displayed, then display next day’s content. (<code class="vk">VK_NEXT_DAY</code>)
505    GuideNextDay,
506    /// If guide is active and displayed, then display previous day’s content. (<code class="vk">VK_PREV_DAY</code>)
507    GuidePreviousDay,
508    /// Toggle display of information about currently selected context or media. (<code class="vk"><code class="vk">VK_INFO</code></code>, <code class="android"><code class="android">KEYCODE_INFO</code></code>)
509    Info,
510    /// Toggle instant replay. (<code class="vk">VK_INSTANT_REPLAY</code>)
511    InstantReplay,
512    /// Launch linked content, if available and appropriate. (<code class="vk">VK_LINK</code>)
513    Link,
514    /// List the current program. (<code class="vk">VK_LIST</code>)
515    ListProgram,
516    /// Toggle display listing of currently available live content or programs. (<code class="vk">VK_LIVE</code>)
517    LiveContent,
518    /// Lock or unlock current content or program. (<code class="vk">VK_LOCK</code>)
519    Lock,
520    /// Show a list of media applications: audio/video players and image viewers. (<code class="vk">VK_APPS</code>)
521    /// <p class="note" role="note">Do not confuse this key value with the Windows' <code class="vk"><code class="vk">VK_APPS</code></code> / <code class="vk"><code class="vk">VK_CONTEXT_MENU</code></code> key, which is encoded as <code class="key">"ContextMenu"</code>.</p>
522    MediaApps,
523    /// Audio track key. (<code class="android">KEYCODE_MEDIA_AUDIO_TRACK</code>)
524    MediaAudioTrack,
525    /// Select previously selected channel or media. (<code class="vk"><code class="vk">VK_LAST</code></code>, <code class="android"><code class="android">KEYCODE_LAST_CHANNEL</code></code>)
526    MediaLast,
527    /// Skip backward to next content or program. (<code class="android">KEYCODE_MEDIA_SKIP_BACKWARD</code>)
528    MediaSkipBackward,
529    /// Skip forward to next content or program. (<code class="vk"><code class="vk">VK_SKIP</code></code>, <code class="android"><code class="android">KEYCODE_MEDIA_SKIP_FORWARD</code></code>)
530    MediaSkipForward,
531    /// Step backward to next content or program. (<code class="android">KEYCODE_MEDIA_STEP_BACKWARD</code>)
532    MediaStepBackward,
533    /// Step forward to next content or program. (<code class="android">KEYCODE_MEDIA_STEP_FORWARD</code>)
534    MediaStepForward,
535    /// Media top menu. (<code class="android">KEYCODE_MEDIA_TOP_MENU</code>)
536    MediaTopMenu,
537    /// Navigate in. (<code class="android">KEYCODE_NAVIGATE_IN</code>)
538    NavigateIn,
539    /// Navigate to next key. (<code class="android">KEYCODE_NAVIGATE_NEXT</code>)
540    NavigateNext,
541    /// Navigate out. (<code class="android">KEYCODE_NAVIGATE_OUT</code>)
542    NavigateOut,
543    /// Navigate to previous key. (<code class="android">KEYCODE_NAVIGATE_PREVIOUS</code>)
544    NavigatePrevious,
545    /// Cycle to next favorite channel (in favorites list). (<code class="vk">VK_NEXT_FAVORITE_CHANNEL</code>)
546    NextFavoriteChannel,
547    /// Cycle to next user profile (if there are multiple user profiles). (<code class="vk">VK_USER</code>)
548    NextUserProfile,
549    /// Access on-demand content or programs. (<code class="vk">VK_ON_DEMAND</code>)
550    OnDemand,
551    /// Pairing key to pair devices. (<code class="android">KEYCODE_PAIRING</code>)
552    Pairing,
553    /// Move picture-in-picture window down. (<code class="vk">VK_PINP_DOWN</code>)
554    PinPDown,
555    /// Move picture-in-picture window. (<code class="vk">VK_PINP_MOVE</code>)
556    PinPMove,
557    /// Toggle display of picture-in-picture window. (<code class="vk">VK_PINP_TOGGLE</code>)
558    PinPToggle,
559    /// Move picture-in-picture window up. (<code class="vk">VK_PINP_UP</code>)
560    PinPUp,
561    /// Decrease media playback speed. (<code class="vk">VK_PLAY_SPEED_DOWN</code>)
562    PlaySpeedDown,
563    /// Reset playback to normal speed. (<code class="vk">VK_PLAY_SPEED_RESET</code>)
564    PlaySpeedReset,
565    /// Increase media playback speed. (<code class="vk">VK_PLAY_SPEED_UP</code>)
566    PlaySpeedUp,
567    /// Toggle random media or content shuffle mode. (<code class="vk">VK_RANDOM_TOGGLE</code>)
568    RandomToggle,
569    /// Not a physical key, but this key code is sent when the remote control battery is low. (<code class="vk">VK_RC_LOW_BATTERY</code>)
570    RcLowBattery,
571    /// Toggle or cycle between media recording speeds. (<code class="vk">VK_RECORD_SPEED_NEXT</code>)
572    RecordSpeedNext,
573    /// Toggle RF (radio frequency) input bypass mode (pass RF input directly to the RF output). (<code class="vk">VK_RF_BYPASS</code>)
574    RfBypass,
575    /// Toggle scan channels mode. (<code class="vk">VK_SCAN_CHANNELS_TOGGLE</code>)
576    ScanChannelsToggle,
577    /// Advance display screen mode to next available mode. (<code class="vk">VK_SCREEN_MODE_NEXT</code>)
578    ScreenModeNext,
579    /// Toggle display of device settings screen. (<code class="vk"><code class="vk">VK_SETTINGS</code></code>, <code class="android"><code class="android">KEYCODE_SETTINGS</code></code>)
580    Settings,
581    /// Toggle split screen mode. (<code class="vk">VK_SPLIT_SCREEN_TOGGLE</code>)
582    SplitScreenToggle,
583    /// Switch the input mode on an external STB (set top box). (<code class="android">KEYCODE_STB_INPUT</code>)
584    STBInput,
585    /// Toggle the power on an external STB (set top box). (<code class="android">KEYCODE_STB_POWER</code>)
586    STBPower,
587    /// Toggle display of subtitles, if available. (<code class="vk">VK_SUBTITLE</code>)
588    Subtitle,
589    /// Toggle display of teletext, if available (<code class="vk"><code class="vk">VK_TELETEXT</code></code>, <code class="android"><code class="android">KEYCODE_TV_TELETEXT</code></code>).
590    Teletext,
591    /// Advance video mode to next available mode. (<code class="vk">VK_VIDEO_MODE_NEXT</code>)
592    VideoModeNext,
593    /// Cause device to identify itself in some manner, e.g., audibly or visibly. (<code class="vk">VK_WINK</code>)
594    Wink,
595    /// Toggle between full-screen and scaled content, or alter magnification level. (<code class="vk"><code class="vk">VK_ZOOM</code></code>, <code class="android"><code class="android">KEYCODE_TV_ZOOM_MODE</code></code>)
596    ZoomToggle,
597    /// The F1 key, a general purpose function key, as index 1.
598    F1,
599    /// The F2 key, a general purpose function key, as index 2.
600    F2,
601    /// The F3 key, a general purpose function key, as index 3.
602    F3,
603    /// The F4 key, a general purpose function key, as index 4.
604    F4,
605    /// The F5 key, a general purpose function key, as index 5.
606    F5,
607    /// The F6 key, a general purpose function key, as index 6.
608    F6,
609    /// The F7 key, a general purpose function key, as index 7.
610    F7,
611    /// The F8 key, a general purpose function key, as index 8.
612    F8,
613    /// The F9 key, a general purpose function key, as index 9.
614    F9,
615    /// The F10 key, a general purpose function key, as index 10.
616    F10,
617    /// The F11 key, a general purpose function key, as index 11.
618    F11,
619    /// The F12 key, a general purpose function key, as index 12.
620    F12,
621    /// The F13 key, a general purpose function key, as index 13.
622    F13,
623    /// The F14 key, a general purpose function key, as index 14.
624    F14,
625    /// The F15 key, a general purpose function key, as index 15.
626    F15,
627    /// The F16 key, a general purpose function key, as index 16.
628    F16,
629    /// The F17 key, a general purpose function key, as index 17.
630    F17,
631    /// The F18 key, a general purpose function key, as index 18.
632    F18,
633    /// The F19 key, a general purpose function key, as index 19.
634    F19,
635    /// The F20 key, a general purpose function key, as index 20.
636    F20,
637    /// The F21 key, a general purpose function key, as index 21.
638    F21,
639    /// The F22 key, a general purpose function key, as index 22.
640    F22,
641    /// The F23 key, a general purpose function key, as index 23.
642    F23,
643    /// The F24 key, a general purpose function key, as index 24.
644    F24,
645    /// The F25 key, a general purpose function key, as index 25.
646    F25,
647    /// The F26 key, a general purpose function key, as index 26.
648    F26,
649    /// The F27 key, a general purpose function key, as index 27.
650    F27,
651    /// The F28 key, a general purpose function key, as index 28.
652    F28,
653    /// The F29 key, a general purpose function key, as index 29.
654    F29,
655    /// The F30 key, a general purpose function key, as index 30.
656    F30,
657    /// The F31 key, a general purpose function key, as index 31.
658    F31,
659    /// The F32 key, a general purpose function key, as index 32.
660    F32,
661    /// The F33 key, a general purpose function key, as index 33.
662    F33,
663    /// The F34 key, a general purpose function key, as index 34.
664    F34,
665    /// The F35 key, a general purpose function key, as index 35.
666    F35,
667}
668
669
670impl Display for Key {
671    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
672        use self::Key::*;
673        match *self {
674            Character(ref s) => write!(f, "{}", s),
675    
676            Unidentified => f.write_str("Unidentified"),
677            Alt => f.write_str("Alt"),
678            AltGraph => f.write_str("AltGraph"),
679            CapsLock => f.write_str("CapsLock"),
680            Control => f.write_str("Control"),
681            Fn => f.write_str("Fn"),
682            FnLock => f.write_str("FnLock"),
683            Meta => f.write_str("Meta"),
684            NumLock => f.write_str("NumLock"),
685            ScrollLock => f.write_str("ScrollLock"),
686            Shift => f.write_str("Shift"),
687            Symbol => f.write_str("Symbol"),
688            SymbolLock => f.write_str("SymbolLock"),
689            Hyper => f.write_str("Hyper"),
690            Super => f.write_str("Super"),
691            Enter => f.write_str("Enter"),
692            Tab => f.write_str("Tab"),
693            ArrowDown => f.write_str("ArrowDown"),
694            ArrowLeft => f.write_str("ArrowLeft"),
695            ArrowRight => f.write_str("ArrowRight"),
696            ArrowUp => f.write_str("ArrowUp"),
697            End => f.write_str("End"),
698            Home => f.write_str("Home"),
699            PageDown => f.write_str("PageDown"),
700            PageUp => f.write_str("PageUp"),
701            Backspace => f.write_str("Backspace"),
702            Clear => f.write_str("Clear"),
703            Copy => f.write_str("Copy"),
704            CrSel => f.write_str("CrSel"),
705            Cut => f.write_str("Cut"),
706            Delete => f.write_str("Delete"),
707            EraseEof => f.write_str("EraseEof"),
708            ExSel => f.write_str("ExSel"),
709            Insert => f.write_str("Insert"),
710            Paste => f.write_str("Paste"),
711            Redo => f.write_str("Redo"),
712            Undo => f.write_str("Undo"),
713            Accept => f.write_str("Accept"),
714            Again => f.write_str("Again"),
715            Attn => f.write_str("Attn"),
716            Cancel => f.write_str("Cancel"),
717            ContextMenu => f.write_str("ContextMenu"),
718            Escape => f.write_str("Escape"),
719            Execute => f.write_str("Execute"),
720            Find => f.write_str("Find"),
721            Help => f.write_str("Help"),
722            Pause => f.write_str("Pause"),
723            Play => f.write_str("Play"),
724            Props => f.write_str("Props"),
725            Select => f.write_str("Select"),
726            ZoomIn => f.write_str("ZoomIn"),
727            ZoomOut => f.write_str("ZoomOut"),
728            BrightnessDown => f.write_str("BrightnessDown"),
729            BrightnessUp => f.write_str("BrightnessUp"),
730            Eject => f.write_str("Eject"),
731            LogOff => f.write_str("LogOff"),
732            Power => f.write_str("Power"),
733            PowerOff => f.write_str("PowerOff"),
734            PrintScreen => f.write_str("PrintScreen"),
735            Hibernate => f.write_str("Hibernate"),
736            Standby => f.write_str("Standby"),
737            WakeUp => f.write_str("WakeUp"),
738            AllCandidates => f.write_str("AllCandidates"),
739            Alphanumeric => f.write_str("Alphanumeric"),
740            CodeInput => f.write_str("CodeInput"),
741            Compose => f.write_str("Compose"),
742            Convert => f.write_str("Convert"),
743            Dead => f.write_str("Dead"),
744            FinalMode => f.write_str("FinalMode"),
745            GroupFirst => f.write_str("GroupFirst"),
746            GroupLast => f.write_str("GroupLast"),
747            GroupNext => f.write_str("GroupNext"),
748            GroupPrevious => f.write_str("GroupPrevious"),
749            ModeChange => f.write_str("ModeChange"),
750            NextCandidate => f.write_str("NextCandidate"),
751            NonConvert => f.write_str("NonConvert"),
752            PreviousCandidate => f.write_str("PreviousCandidate"),
753            Process => f.write_str("Process"),
754            SingleCandidate => f.write_str("SingleCandidate"),
755            HangulMode => f.write_str("HangulMode"),
756            HanjaMode => f.write_str("HanjaMode"),
757            JunjaMode => f.write_str("JunjaMode"),
758            Eisu => f.write_str("Eisu"),
759            Hankaku => f.write_str("Hankaku"),
760            Hiragana => f.write_str("Hiragana"),
761            HiraganaKatakana => f.write_str("HiraganaKatakana"),
762            KanaMode => f.write_str("KanaMode"),
763            KanjiMode => f.write_str("KanjiMode"),
764            Katakana => f.write_str("Katakana"),
765            Romaji => f.write_str("Romaji"),
766            Zenkaku => f.write_str("Zenkaku"),
767            ZenkakuHankaku => f.write_str("ZenkakuHankaku"),
768            Soft1 => f.write_str("Soft1"),
769            Soft2 => f.write_str("Soft2"),
770            Soft3 => f.write_str("Soft3"),
771            Soft4 => f.write_str("Soft4"),
772            ChannelDown => f.write_str("ChannelDown"),
773            ChannelUp => f.write_str("ChannelUp"),
774            Close => f.write_str("Close"),
775            MailForward => f.write_str("MailForward"),
776            MailReply => f.write_str("MailReply"),
777            MailSend => f.write_str("MailSend"),
778            MediaClose => f.write_str("MediaClose"),
779            MediaFastForward => f.write_str("MediaFastForward"),
780            MediaPause => f.write_str("MediaPause"),
781            MediaPlay => f.write_str("MediaPlay"),
782            MediaPlayPause => f.write_str("MediaPlayPause"),
783            MediaRecord => f.write_str("MediaRecord"),
784            MediaRewind => f.write_str("MediaRewind"),
785            MediaStop => f.write_str("MediaStop"),
786            MediaTrackNext => f.write_str("MediaTrackNext"),
787            MediaTrackPrevious => f.write_str("MediaTrackPrevious"),
788            New => f.write_str("New"),
789            Open => f.write_str("Open"),
790            Print => f.write_str("Print"),
791            Save => f.write_str("Save"),
792            SpellCheck => f.write_str("SpellCheck"),
793            Key11 => f.write_str("Key11"),
794            Key12 => f.write_str("Key12"),
795            AudioBalanceLeft => f.write_str("AudioBalanceLeft"),
796            AudioBalanceRight => f.write_str("AudioBalanceRight"),
797            AudioBassBoostDown => f.write_str("AudioBassBoostDown"),
798            AudioBassBoostToggle => f.write_str("AudioBassBoostToggle"),
799            AudioBassBoostUp => f.write_str("AudioBassBoostUp"),
800            AudioFaderFront => f.write_str("AudioFaderFront"),
801            AudioFaderRear => f.write_str("AudioFaderRear"),
802            AudioSurroundModeNext => f.write_str("AudioSurroundModeNext"),
803            AudioTrebleDown => f.write_str("AudioTrebleDown"),
804            AudioTrebleUp => f.write_str("AudioTrebleUp"),
805            AudioVolumeDown => f.write_str("AudioVolumeDown"),
806            AudioVolumeUp => f.write_str("AudioVolumeUp"),
807            AudioVolumeMute => f.write_str("AudioVolumeMute"),
808            MicrophoneToggle => f.write_str("MicrophoneToggle"),
809            MicrophoneVolumeDown => f.write_str("MicrophoneVolumeDown"),
810            MicrophoneVolumeUp => f.write_str("MicrophoneVolumeUp"),
811            MicrophoneVolumeMute => f.write_str("MicrophoneVolumeMute"),
812            SpeechCorrectionList => f.write_str("SpeechCorrectionList"),
813            SpeechInputToggle => f.write_str("SpeechInputToggle"),
814            LaunchApplication1 => f.write_str("LaunchApplication1"),
815            LaunchApplication2 => f.write_str("LaunchApplication2"),
816            LaunchCalendar => f.write_str("LaunchCalendar"),
817            LaunchContacts => f.write_str("LaunchContacts"),
818            LaunchMail => f.write_str("LaunchMail"),
819            LaunchMediaPlayer => f.write_str("LaunchMediaPlayer"),
820            LaunchMusicPlayer => f.write_str("LaunchMusicPlayer"),
821            LaunchPhone => f.write_str("LaunchPhone"),
822            LaunchScreenSaver => f.write_str("LaunchScreenSaver"),
823            LaunchSpreadsheet => f.write_str("LaunchSpreadsheet"),
824            LaunchWebBrowser => f.write_str("LaunchWebBrowser"),
825            LaunchWebCam => f.write_str("LaunchWebCam"),
826            LaunchWordProcessor => f.write_str("LaunchWordProcessor"),
827            BrowserBack => f.write_str("BrowserBack"),
828            BrowserFavorites => f.write_str("BrowserFavorites"),
829            BrowserForward => f.write_str("BrowserForward"),
830            BrowserHome => f.write_str("BrowserHome"),
831            BrowserRefresh => f.write_str("BrowserRefresh"),
832            BrowserSearch => f.write_str("BrowserSearch"),
833            BrowserStop => f.write_str("BrowserStop"),
834            AppSwitch => f.write_str("AppSwitch"),
835            Call => f.write_str("Call"),
836            Camera => f.write_str("Camera"),
837            CameraFocus => f.write_str("CameraFocus"),
838            EndCall => f.write_str("EndCall"),
839            GoBack => f.write_str("GoBack"),
840            GoHome => f.write_str("GoHome"),
841            HeadsetHook => f.write_str("HeadsetHook"),
842            LastNumberRedial => f.write_str("LastNumberRedial"),
843            Notification => f.write_str("Notification"),
844            MannerMode => f.write_str("MannerMode"),
845            VoiceDial => f.write_str("VoiceDial"),
846            TV => f.write_str("TV"),
847            TV3DMode => f.write_str("TV3DMode"),
848            TVAntennaCable => f.write_str("TVAntennaCable"),
849            TVAudioDescription => f.write_str("TVAudioDescription"),
850            TVAudioDescriptionMixDown => f.write_str("TVAudioDescriptionMixDown"),
851            TVAudioDescriptionMixUp => f.write_str("TVAudioDescriptionMixUp"),
852            TVContentsMenu => f.write_str("TVContentsMenu"),
853            TVDataService => f.write_str("TVDataService"),
854            TVInput => f.write_str("TVInput"),
855            TVInputComponent1 => f.write_str("TVInputComponent1"),
856            TVInputComponent2 => f.write_str("TVInputComponent2"),
857            TVInputComposite1 => f.write_str("TVInputComposite1"),
858            TVInputComposite2 => f.write_str("TVInputComposite2"),
859            TVInputHDMI1 => f.write_str("TVInputHDMI1"),
860            TVInputHDMI2 => f.write_str("TVInputHDMI2"),
861            TVInputHDMI3 => f.write_str("TVInputHDMI3"),
862            TVInputHDMI4 => f.write_str("TVInputHDMI4"),
863            TVInputVGA1 => f.write_str("TVInputVGA1"),
864            TVMediaContext => f.write_str("TVMediaContext"),
865            TVNetwork => f.write_str("TVNetwork"),
866            TVNumberEntry => f.write_str("TVNumberEntry"),
867            TVPower => f.write_str("TVPower"),
868            TVRadioService => f.write_str("TVRadioService"),
869            TVSatellite => f.write_str("TVSatellite"),
870            TVSatelliteBS => f.write_str("TVSatelliteBS"),
871            TVSatelliteCS => f.write_str("TVSatelliteCS"),
872            TVSatelliteToggle => f.write_str("TVSatelliteToggle"),
873            TVTerrestrialAnalog => f.write_str("TVTerrestrialAnalog"),
874            TVTerrestrialDigital => f.write_str("TVTerrestrialDigital"),
875            TVTimer => f.write_str("TVTimer"),
876            AVRInput => f.write_str("AVRInput"),
877            AVRPower => f.write_str("AVRPower"),
878            ColorF0Red => f.write_str("ColorF0Red"),
879            ColorF1Green => f.write_str("ColorF1Green"),
880            ColorF2Yellow => f.write_str("ColorF2Yellow"),
881            ColorF3Blue => f.write_str("ColorF3Blue"),
882            ColorF4Grey => f.write_str("ColorF4Grey"),
883            ColorF5Brown => f.write_str("ColorF5Brown"),
884            ClosedCaptionToggle => f.write_str("ClosedCaptionToggle"),
885            Dimmer => f.write_str("Dimmer"),
886            DisplaySwap => f.write_str("DisplaySwap"),
887            DVR => f.write_str("DVR"),
888            Exit => f.write_str("Exit"),
889            FavoriteClear0 => f.write_str("FavoriteClear0"),
890            FavoriteClear1 => f.write_str("FavoriteClear1"),
891            FavoriteClear2 => f.write_str("FavoriteClear2"),
892            FavoriteClear3 => f.write_str("FavoriteClear3"),
893            FavoriteRecall0 => f.write_str("FavoriteRecall0"),
894            FavoriteRecall1 => f.write_str("FavoriteRecall1"),
895            FavoriteRecall2 => f.write_str("FavoriteRecall2"),
896            FavoriteRecall3 => f.write_str("FavoriteRecall3"),
897            FavoriteStore0 => f.write_str("FavoriteStore0"),
898            FavoriteStore1 => f.write_str("FavoriteStore1"),
899            FavoriteStore2 => f.write_str("FavoriteStore2"),
900            FavoriteStore3 => f.write_str("FavoriteStore3"),
901            Guide => f.write_str("Guide"),
902            GuideNextDay => f.write_str("GuideNextDay"),
903            GuidePreviousDay => f.write_str("GuidePreviousDay"),
904            Info => f.write_str("Info"),
905            InstantReplay => f.write_str("InstantReplay"),
906            Link => f.write_str("Link"),
907            ListProgram => f.write_str("ListProgram"),
908            LiveContent => f.write_str("LiveContent"),
909            Lock => f.write_str("Lock"),
910            MediaApps => f.write_str("MediaApps"),
911            MediaAudioTrack => f.write_str("MediaAudioTrack"),
912            MediaLast => f.write_str("MediaLast"),
913            MediaSkipBackward => f.write_str("MediaSkipBackward"),
914            MediaSkipForward => f.write_str("MediaSkipForward"),
915            MediaStepBackward => f.write_str("MediaStepBackward"),
916            MediaStepForward => f.write_str("MediaStepForward"),
917            MediaTopMenu => f.write_str("MediaTopMenu"),
918            NavigateIn => f.write_str("NavigateIn"),
919            NavigateNext => f.write_str("NavigateNext"),
920            NavigateOut => f.write_str("NavigateOut"),
921            NavigatePrevious => f.write_str("NavigatePrevious"),
922            NextFavoriteChannel => f.write_str("NextFavoriteChannel"),
923            NextUserProfile => f.write_str("NextUserProfile"),
924            OnDemand => f.write_str("OnDemand"),
925            Pairing => f.write_str("Pairing"),
926            PinPDown => f.write_str("PinPDown"),
927            PinPMove => f.write_str("PinPMove"),
928            PinPToggle => f.write_str("PinPToggle"),
929            PinPUp => f.write_str("PinPUp"),
930            PlaySpeedDown => f.write_str("PlaySpeedDown"),
931            PlaySpeedReset => f.write_str("PlaySpeedReset"),
932            PlaySpeedUp => f.write_str("PlaySpeedUp"),
933            RandomToggle => f.write_str("RandomToggle"),
934            RcLowBattery => f.write_str("RcLowBattery"),
935            RecordSpeedNext => f.write_str("RecordSpeedNext"),
936            RfBypass => f.write_str("RfBypass"),
937            ScanChannelsToggle => f.write_str("ScanChannelsToggle"),
938            ScreenModeNext => f.write_str("ScreenModeNext"),
939            Settings => f.write_str("Settings"),
940            SplitScreenToggle => f.write_str("SplitScreenToggle"),
941            STBInput => f.write_str("STBInput"),
942            STBPower => f.write_str("STBPower"),
943            Subtitle => f.write_str("Subtitle"),
944            Teletext => f.write_str("Teletext"),
945            VideoModeNext => f.write_str("VideoModeNext"),
946            Wink => f.write_str("Wink"),
947            ZoomToggle => f.write_str("ZoomToggle"),
948            F1 => f.write_str("F1"),
949            F2 => f.write_str("F2"),
950            F3 => f.write_str("F3"),
951            F4 => f.write_str("F4"),
952            F5 => f.write_str("F5"),
953            F6 => f.write_str("F6"),
954            F7 => f.write_str("F7"),
955            F8 => f.write_str("F8"),
956            F9 => f.write_str("F9"),
957            F10 => f.write_str("F10"),
958            F11 => f.write_str("F11"),
959            F12 => f.write_str("F12"),
960            F13 => f.write_str("F13"),
961            F14 => f.write_str("F14"),
962            F15 => f.write_str("F15"),
963            F16 => f.write_str("F16"),
964            F17 => f.write_str("F17"),
965            F18 => f.write_str("F18"),
966            F19 => f.write_str("F19"),
967            F20 => f.write_str("F20"),
968            F21 => f.write_str("F21"),
969            F22 => f.write_str("F22"),
970            F23 => f.write_str("F23"),
971            F24 => f.write_str("F24"),
972            F25 => f.write_str("F25"),
973            F26 => f.write_str("F26"),
974            F27 => f.write_str("F27"),
975            F28 => f.write_str("F28"),
976            F29 => f.write_str("F29"),
977            F30 => f.write_str("F30"),
978            F31 => f.write_str("F31"),
979            F32 => f.write_str("F32"),
980            F33 => f.write_str("F33"),
981            F34 => f.write_str("F34"),
982            F35 => f.write_str("F35"),
983
984        }
985    }
986}
987
988impl FromStr for Key {
989    type Err = UnrecognizedKeyError;
990
991    fn from_str(s: &str) -> Result<Self, Self::Err> {
992        use crate::Key::*;
993        match s {
994            s if is_key_string(s) => Ok(Character(s.to_string())),
995            "Unidentified" => Ok(Unidentified),
996            "Alt" => Ok(Alt),
997            "AltGraph" => Ok(AltGraph),
998            "CapsLock" => Ok(CapsLock),
999            "Control" => Ok(Control),
1000            "Fn" => Ok(Fn),
1001            "FnLock" => Ok(FnLock),
1002            "Meta" => Ok(Meta),
1003            "NumLock" => Ok(NumLock),
1004            "ScrollLock" => Ok(ScrollLock),
1005            "Shift" => Ok(Shift),
1006            "Symbol" => Ok(Symbol),
1007            "SymbolLock" => Ok(SymbolLock),
1008            "Hyper" => Ok(Hyper),
1009            "Super" => Ok(Super),
1010            "Enter" => Ok(Enter),
1011            "Tab" => Ok(Tab),
1012            "ArrowDown" => Ok(ArrowDown),
1013            "ArrowLeft" => Ok(ArrowLeft),
1014            "ArrowRight" => Ok(ArrowRight),
1015            "ArrowUp" => Ok(ArrowUp),
1016            "End" => Ok(End),
1017            "Home" => Ok(Home),
1018            "PageDown" => Ok(PageDown),
1019            "PageUp" => Ok(PageUp),
1020            "Backspace" => Ok(Backspace),
1021            "Clear" => Ok(Clear),
1022            "Copy" => Ok(Copy),
1023            "CrSel" => Ok(CrSel),
1024            "Cut" => Ok(Cut),
1025            "Delete" => Ok(Delete),
1026            "EraseEof" => Ok(EraseEof),
1027            "ExSel" => Ok(ExSel),
1028            "Insert" => Ok(Insert),
1029            "Paste" => Ok(Paste),
1030            "Redo" => Ok(Redo),
1031            "Undo" => Ok(Undo),
1032            "Accept" => Ok(Accept),
1033            "Again" => Ok(Again),
1034            "Attn" => Ok(Attn),
1035            "Cancel" => Ok(Cancel),
1036            "ContextMenu" => Ok(ContextMenu),
1037            "Escape" => Ok(Escape),
1038            "Execute" => Ok(Execute),
1039            "Find" => Ok(Find),
1040            "Help" => Ok(Help),
1041            "Pause" => Ok(Pause),
1042            "Play" => Ok(Play),
1043            "Props" => Ok(Props),
1044            "Select" => Ok(Select),
1045            "ZoomIn" => Ok(ZoomIn),
1046            "ZoomOut" => Ok(ZoomOut),
1047            "BrightnessDown" => Ok(BrightnessDown),
1048            "BrightnessUp" => Ok(BrightnessUp),
1049            "Eject" => Ok(Eject),
1050            "LogOff" => Ok(LogOff),
1051            "Power" => Ok(Power),
1052            "PowerOff" => Ok(PowerOff),
1053            "PrintScreen" => Ok(PrintScreen),
1054            "Hibernate" => Ok(Hibernate),
1055            "Standby" => Ok(Standby),
1056            "WakeUp" => Ok(WakeUp),
1057            "AllCandidates" => Ok(AllCandidates),
1058            "Alphanumeric" => Ok(Alphanumeric),
1059            "CodeInput" => Ok(CodeInput),
1060            "Compose" => Ok(Compose),
1061            "Convert" => Ok(Convert),
1062            "Dead" => Ok(Dead),
1063            "FinalMode" => Ok(FinalMode),
1064            "GroupFirst" => Ok(GroupFirst),
1065            "GroupLast" => Ok(GroupLast),
1066            "GroupNext" => Ok(GroupNext),
1067            "GroupPrevious" => Ok(GroupPrevious),
1068            "ModeChange" => Ok(ModeChange),
1069            "NextCandidate" => Ok(NextCandidate),
1070            "NonConvert" => Ok(NonConvert),
1071            "PreviousCandidate" => Ok(PreviousCandidate),
1072            "Process" => Ok(Process),
1073            "SingleCandidate" => Ok(SingleCandidate),
1074            "HangulMode" => Ok(HangulMode),
1075            "HanjaMode" => Ok(HanjaMode),
1076            "JunjaMode" => Ok(JunjaMode),
1077            "Eisu" => Ok(Eisu),
1078            "Hankaku" => Ok(Hankaku),
1079            "Hiragana" => Ok(Hiragana),
1080            "HiraganaKatakana" => Ok(HiraganaKatakana),
1081            "KanaMode" => Ok(KanaMode),
1082            "KanjiMode" => Ok(KanjiMode),
1083            "Katakana" => Ok(Katakana),
1084            "Romaji" => Ok(Romaji),
1085            "Zenkaku" => Ok(Zenkaku),
1086            "ZenkakuHankaku" => Ok(ZenkakuHankaku),
1087            "Soft1" => Ok(Soft1),
1088            "Soft2" => Ok(Soft2),
1089            "Soft3" => Ok(Soft3),
1090            "Soft4" => Ok(Soft4),
1091            "ChannelDown" => Ok(ChannelDown),
1092            "ChannelUp" => Ok(ChannelUp),
1093            "Close" => Ok(Close),
1094            "MailForward" => Ok(MailForward),
1095            "MailReply" => Ok(MailReply),
1096            "MailSend" => Ok(MailSend),
1097            "MediaClose" => Ok(MediaClose),
1098            "MediaFastForward" => Ok(MediaFastForward),
1099            "MediaPause" => Ok(MediaPause),
1100            "MediaPlay" => Ok(MediaPlay),
1101            "MediaPlayPause" => Ok(MediaPlayPause),
1102            "MediaRecord" => Ok(MediaRecord),
1103            "MediaRewind" => Ok(MediaRewind),
1104            "MediaStop" => Ok(MediaStop),
1105            "MediaTrackNext" => Ok(MediaTrackNext),
1106            "MediaTrackPrevious" => Ok(MediaTrackPrevious),
1107            "New" => Ok(New),
1108            "Open" => Ok(Open),
1109            "Print" => Ok(Print),
1110            "Save" => Ok(Save),
1111            "SpellCheck" => Ok(SpellCheck),
1112            "Key11" => Ok(Key11),
1113            "Key12" => Ok(Key12),
1114            "AudioBalanceLeft" => Ok(AudioBalanceLeft),
1115            "AudioBalanceRight" => Ok(AudioBalanceRight),
1116            "AudioBassBoostDown" => Ok(AudioBassBoostDown),
1117            "AudioBassBoostToggle" => Ok(AudioBassBoostToggle),
1118            "AudioBassBoostUp" => Ok(AudioBassBoostUp),
1119            "AudioFaderFront" => Ok(AudioFaderFront),
1120            "AudioFaderRear" => Ok(AudioFaderRear),
1121            "AudioSurroundModeNext" => Ok(AudioSurroundModeNext),
1122            "AudioTrebleDown" => Ok(AudioTrebleDown),
1123            "AudioTrebleUp" => Ok(AudioTrebleUp),
1124            "AudioVolumeDown" => Ok(AudioVolumeDown),
1125            "AudioVolumeUp" => Ok(AudioVolumeUp),
1126            "AudioVolumeMute" => Ok(AudioVolumeMute),
1127            "MicrophoneToggle" => Ok(MicrophoneToggle),
1128            "MicrophoneVolumeDown" => Ok(MicrophoneVolumeDown),
1129            "MicrophoneVolumeUp" => Ok(MicrophoneVolumeUp),
1130            "MicrophoneVolumeMute" => Ok(MicrophoneVolumeMute),
1131            "SpeechCorrectionList" => Ok(SpeechCorrectionList),
1132            "SpeechInputToggle" => Ok(SpeechInputToggle),
1133            "LaunchApplication1" => Ok(LaunchApplication1),
1134            "LaunchApplication2" => Ok(LaunchApplication2),
1135            "LaunchCalendar" => Ok(LaunchCalendar),
1136            "LaunchContacts" => Ok(LaunchContacts),
1137            "LaunchMail" => Ok(LaunchMail),
1138            "LaunchMediaPlayer" => Ok(LaunchMediaPlayer),
1139            "LaunchMusicPlayer" => Ok(LaunchMusicPlayer),
1140            "LaunchPhone" => Ok(LaunchPhone),
1141            "LaunchScreenSaver" => Ok(LaunchScreenSaver),
1142            "LaunchSpreadsheet" => Ok(LaunchSpreadsheet),
1143            "LaunchWebBrowser" => Ok(LaunchWebBrowser),
1144            "LaunchWebCam" => Ok(LaunchWebCam),
1145            "LaunchWordProcessor" => Ok(LaunchWordProcessor),
1146            "BrowserBack" => Ok(BrowserBack),
1147            "BrowserFavorites" => Ok(BrowserFavorites),
1148            "BrowserForward" => Ok(BrowserForward),
1149            "BrowserHome" => Ok(BrowserHome),
1150            "BrowserRefresh" => Ok(BrowserRefresh),
1151            "BrowserSearch" => Ok(BrowserSearch),
1152            "BrowserStop" => Ok(BrowserStop),
1153            "AppSwitch" => Ok(AppSwitch),
1154            "Call" => Ok(Call),
1155            "Camera" => Ok(Camera),
1156            "CameraFocus" => Ok(CameraFocus),
1157            "EndCall" => Ok(EndCall),
1158            "GoBack" => Ok(GoBack),
1159            "GoHome" => Ok(GoHome),
1160            "HeadsetHook" => Ok(HeadsetHook),
1161            "LastNumberRedial" => Ok(LastNumberRedial),
1162            "Notification" => Ok(Notification),
1163            "MannerMode" => Ok(MannerMode),
1164            "VoiceDial" => Ok(VoiceDial),
1165            "TV" => Ok(TV),
1166            "TV3DMode" => Ok(TV3DMode),
1167            "TVAntennaCable" => Ok(TVAntennaCable),
1168            "TVAudioDescription" => Ok(TVAudioDescription),
1169            "TVAudioDescriptionMixDown" => Ok(TVAudioDescriptionMixDown),
1170            "TVAudioDescriptionMixUp" => Ok(TVAudioDescriptionMixUp),
1171            "TVContentsMenu" => Ok(TVContentsMenu),
1172            "TVDataService" => Ok(TVDataService),
1173            "TVInput" => Ok(TVInput),
1174            "TVInputComponent1" => Ok(TVInputComponent1),
1175            "TVInputComponent2" => Ok(TVInputComponent2),
1176            "TVInputComposite1" => Ok(TVInputComposite1),
1177            "TVInputComposite2" => Ok(TVInputComposite2),
1178            "TVInputHDMI1" => Ok(TVInputHDMI1),
1179            "TVInputHDMI2" => Ok(TVInputHDMI2),
1180            "TVInputHDMI3" => Ok(TVInputHDMI3),
1181            "TVInputHDMI4" => Ok(TVInputHDMI4),
1182            "TVInputVGA1" => Ok(TVInputVGA1),
1183            "TVMediaContext" => Ok(TVMediaContext),
1184            "TVNetwork" => Ok(TVNetwork),
1185            "TVNumberEntry" => Ok(TVNumberEntry),
1186            "TVPower" => Ok(TVPower),
1187            "TVRadioService" => Ok(TVRadioService),
1188            "TVSatellite" => Ok(TVSatellite),
1189            "TVSatelliteBS" => Ok(TVSatelliteBS),
1190            "TVSatelliteCS" => Ok(TVSatelliteCS),
1191            "TVSatelliteToggle" => Ok(TVSatelliteToggle),
1192            "TVTerrestrialAnalog" => Ok(TVTerrestrialAnalog),
1193            "TVTerrestrialDigital" => Ok(TVTerrestrialDigital),
1194            "TVTimer" => Ok(TVTimer),
1195            "AVRInput" => Ok(AVRInput),
1196            "AVRPower" => Ok(AVRPower),
1197            "ColorF0Red" => Ok(ColorF0Red),
1198            "ColorF1Green" => Ok(ColorF1Green),
1199            "ColorF2Yellow" => Ok(ColorF2Yellow),
1200            "ColorF3Blue" => Ok(ColorF3Blue),
1201            "ColorF4Grey" => Ok(ColorF4Grey),
1202            "ColorF5Brown" => Ok(ColorF5Brown),
1203            "ClosedCaptionToggle" => Ok(ClosedCaptionToggle),
1204            "Dimmer" => Ok(Dimmer),
1205            "DisplaySwap" => Ok(DisplaySwap),
1206            "DVR" => Ok(DVR),
1207            "Exit" => Ok(Exit),
1208            "FavoriteClear0" => Ok(FavoriteClear0),
1209            "FavoriteClear1" => Ok(FavoriteClear1),
1210            "FavoriteClear2" => Ok(FavoriteClear2),
1211            "FavoriteClear3" => Ok(FavoriteClear3),
1212            "FavoriteRecall0" => Ok(FavoriteRecall0),
1213            "FavoriteRecall1" => Ok(FavoriteRecall1),
1214            "FavoriteRecall2" => Ok(FavoriteRecall2),
1215            "FavoriteRecall3" => Ok(FavoriteRecall3),
1216            "FavoriteStore0" => Ok(FavoriteStore0),
1217            "FavoriteStore1" => Ok(FavoriteStore1),
1218            "FavoriteStore2" => Ok(FavoriteStore2),
1219            "FavoriteStore3" => Ok(FavoriteStore3),
1220            "Guide" => Ok(Guide),
1221            "GuideNextDay" => Ok(GuideNextDay),
1222            "GuidePreviousDay" => Ok(GuidePreviousDay),
1223            "Info" => Ok(Info),
1224            "InstantReplay" => Ok(InstantReplay),
1225            "Link" => Ok(Link),
1226            "ListProgram" => Ok(ListProgram),
1227            "LiveContent" => Ok(LiveContent),
1228            "Lock" => Ok(Lock),
1229            "MediaApps" => Ok(MediaApps),
1230            "MediaAudioTrack" => Ok(MediaAudioTrack),
1231            "MediaLast" => Ok(MediaLast),
1232            "MediaSkipBackward" => Ok(MediaSkipBackward),
1233            "MediaSkipForward" => Ok(MediaSkipForward),
1234            "MediaStepBackward" => Ok(MediaStepBackward),
1235            "MediaStepForward" => Ok(MediaStepForward),
1236            "MediaTopMenu" => Ok(MediaTopMenu),
1237            "NavigateIn" => Ok(NavigateIn),
1238            "NavigateNext" => Ok(NavigateNext),
1239            "NavigateOut" => Ok(NavigateOut),
1240            "NavigatePrevious" => Ok(NavigatePrevious),
1241            "NextFavoriteChannel" => Ok(NextFavoriteChannel),
1242            "NextUserProfile" => Ok(NextUserProfile),
1243            "OnDemand" => Ok(OnDemand),
1244            "Pairing" => Ok(Pairing),
1245            "PinPDown" => Ok(PinPDown),
1246            "PinPMove" => Ok(PinPMove),
1247            "PinPToggle" => Ok(PinPToggle),
1248            "PinPUp" => Ok(PinPUp),
1249            "PlaySpeedDown" => Ok(PlaySpeedDown),
1250            "PlaySpeedReset" => Ok(PlaySpeedReset),
1251            "PlaySpeedUp" => Ok(PlaySpeedUp),
1252            "RandomToggle" => Ok(RandomToggle),
1253            "RcLowBattery" => Ok(RcLowBattery),
1254            "RecordSpeedNext" => Ok(RecordSpeedNext),
1255            "RfBypass" => Ok(RfBypass),
1256            "ScanChannelsToggle" => Ok(ScanChannelsToggle),
1257            "ScreenModeNext" => Ok(ScreenModeNext),
1258            "Settings" => Ok(Settings),
1259            "SplitScreenToggle" => Ok(SplitScreenToggle),
1260            "STBInput" => Ok(STBInput),
1261            "STBPower" => Ok(STBPower),
1262            "Subtitle" => Ok(Subtitle),
1263            "Teletext" => Ok(Teletext),
1264            "VideoModeNext" => Ok(VideoModeNext),
1265            "Wink" => Ok(Wink),
1266            "ZoomToggle" => Ok(ZoomToggle),
1267            "F1" => Ok(F1),
1268            "F2" => Ok(F2),
1269            "F3" => Ok(F3),
1270            "F4" => Ok(F4),
1271            "F5" => Ok(F5),
1272            "F6" => Ok(F6),
1273            "F7" => Ok(F7),
1274            "F8" => Ok(F8),
1275            "F9" => Ok(F9),
1276            "F10" => Ok(F10),
1277            "F11" => Ok(F11),
1278            "F12" => Ok(F12),
1279            "F13" => Ok(F13),
1280            "F14" => Ok(F14),
1281            "F15" => Ok(F15),
1282            "F16" => Ok(F16),
1283            "F17" => Ok(F17),
1284            "F18" => Ok(F18),
1285            "F19" => Ok(F19),
1286            "F20" => Ok(F20),
1287            "F21" => Ok(F21),
1288            "F22" => Ok(F22),
1289            "F23" => Ok(F23),
1290            "F24" => Ok(F24),
1291            "F25" => Ok(F25),
1292            "F26" => Ok(F26),
1293            "F27" => Ok(F27),
1294            "F28" => Ok(F28),
1295            "F29" => Ok(F29),
1296            "F30" => Ok(F30),
1297            "F31" => Ok(F31),
1298            "F32" => Ok(F32),
1299            "F33" => Ok(F33),
1300            "F34" => Ok(F34),
1301            "F35" => Ok(F35),
1302
1303            _ => Err(UnrecognizedKeyError),
1304        }
1305    }
1306}
1307
1308/// Parse from string error, returned when string does not match to any Key variant.
1309#[derive(Clone, Debug)]
1310pub struct UnrecognizedKeyError;
1311
1312impl fmt::Display for UnrecognizedKeyError {
1313    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1314        write!(f, "Unrecognized key")
1315    }
1316}
1317
1318impl Error for UnrecognizedKeyError {}
1319
1320/// Check if string can be used as a `Key::Character` _keystring_.
1321///
1322/// This check is simple and is meant to prevents common mistakes like mistyped keynames
1323/// (e.g. `Ennter`) from being recognized as characters.
1324fn is_key_string(s: &str) -> bool {
1325    s.chars().all(|c| !c.is_control()) && s.chars().skip(1).all(|c| !c.is_ascii())
1326}
1327
1328#[cfg(test)]
1329mod test {
1330    use super::*;
1331
1332    #[test]
1333    fn test_is_key_string() {
1334        assert!(is_key_string("A"));
1335        assert!(!is_key_string("AA"));
1336        assert!(!is_key_string("	"));
1337    }
1338}
1339