iced_core/keyboard/
key.rs

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