notan_core/
keyboard.rs

1/// KeyCode represents the symbolic name of the keyboard keys pressed
2/// This enum code comes from `winit` just adding the Unknown key for non-compatible keys between platforms
3#[derive(Debug, Hash, Ord, PartialOrd, PartialEq, Eq, Clone, Copy)]
4#[repr(u32)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6pub enum KeyCode {
7    /// <kbd>`</kbd> on a US keyboard. This is also called a backtick or grave.
8    /// This is the <kbd>半角</kbd>/<kbd>全角</kbd>/<kbd>漢字</kbd>
9    /// (hankaku/zenkaku/kanji) key on Japanese keyboards
10    Backquote,
11    /// Used for both the US <kbd>\\</kbd> (on the 101-key layout) and also for the key
12    /// located between the <kbd>"</kbd> and <kbd>Enter</kbd> keys on row C of the 102-,
13    /// 104- and 106-key layouts.
14    /// Labeled <kbd>#</kbd> on a UK (102) keyboard.
15    Backslash,
16    /// <kbd>[</kbd> on a US keyboard.
17    BracketLeft,
18    /// <kbd>]</kbd> on a US keyboard.
19    BracketRight,
20    /// <kbd>,</kbd> on a US keyboard.
21    Comma,
22    /// <kbd>0</kbd> on a US keyboard.
23    Digit0,
24    /// <kbd>1</kbd> on a US keyboard.
25    Digit1,
26    /// <kbd>2</kbd> on a US keyboard.
27    Digit2,
28    /// <kbd>3</kbd> on a US keyboard.
29    Digit3,
30    /// <kbd>4</kbd> on a US keyboard.
31    Digit4,
32    /// <kbd>5</kbd> on a US keyboard.
33    Digit5,
34    /// <kbd>6</kbd> on a US keyboard.
35    Digit6,
36    /// <kbd>7</kbd> on a US keyboard.
37    Digit7,
38    /// <kbd>8</kbd> on a US keyboard.
39    Digit8,
40    /// <kbd>9</kbd> on a US keyboard.
41    Digit9,
42    /// <kbd>=</kbd> on a US keyboard.
43    Equal,
44    /// Located between the left <kbd>Shift</kbd> and <kbd>Z</kbd> keys.
45    /// Labeled <kbd>\\</kbd> on a UK keyboard.
46    IntlBackslash,
47    /// Located between the <kbd>/</kbd> and right <kbd>Shift</kbd> keys.
48    /// Labeled <kbd>\\</kbd> (ro) on a Japanese keyboard.
49    IntlRo,
50    /// Located between the <kbd>=</kbd> and <kbd>Backspace</kbd> keys.
51    /// Labeled <kbd>¥</kbd> (yen) on a Japanese keyboard. <kbd>\\</kbd> on a
52    /// Russian keyboard.
53    IntlYen,
54    /// <kbd>a</kbd> on a US keyboard.
55    /// Labeled <kbd>q</kbd> on an AZERTY (e.g., French) keyboard.
56    KeyA,
57    /// <kbd>b</kbd> on a US keyboard.
58    KeyB,
59    /// <kbd>c</kbd> on a US keyboard.
60    KeyC,
61    /// <kbd>d</kbd> on a US keyboard.
62    KeyD,
63    /// <kbd>e</kbd> on a US keyboard.
64    KeyE,
65    /// <kbd>f</kbd> on a US keyboard.
66    KeyF,
67    /// <kbd>g</kbd> on a US keyboard.
68    KeyG,
69    /// <kbd>h</kbd> on a US keyboard.
70    KeyH,
71    /// <kbd>i</kbd> on a US keyboard.
72    KeyI,
73    /// <kbd>j</kbd> on a US keyboard.
74    KeyJ,
75    /// <kbd>k</kbd> on a US keyboard.
76    KeyK,
77    /// <kbd>l</kbd> on a US keyboard.
78    KeyL,
79    /// <kbd>m</kbd> on a US keyboard.
80    KeyM,
81    /// <kbd>n</kbd> on a US keyboard.
82    KeyN,
83    /// <kbd>o</kbd> on a US keyboard.
84    KeyO,
85    /// <kbd>p</kbd> on a US keyboard.
86    KeyP,
87    /// <kbd>q</kbd> on a US keyboard.
88    /// Labeled <kbd>a</kbd> on an AZERTY (e.g., French) keyboard.
89    KeyQ,
90    /// <kbd>r</kbd> on a US keyboard.
91    KeyR,
92    /// <kbd>s</kbd> on a US keyboard.
93    KeyS,
94    /// <kbd>t</kbd> on a US keyboard.
95    KeyT,
96    /// <kbd>u</kbd> on a US keyboard.
97    KeyU,
98    /// <kbd>v</kbd> on a US keyboard.
99    KeyV,
100    /// <kbd>w</kbd> on a US keyboard.
101    /// Labeled <kbd>z</kbd> on an AZERTY (e.g., French) keyboard.
102    KeyW,
103    /// <kbd>x</kbd> on a US keyboard.
104    KeyX,
105    /// <kbd>y</kbd> on a US keyboard.
106    /// Labeled <kbd>z</kbd> on a QWERTZ (e.g., German) keyboard.
107    KeyY,
108    /// <kbd>z</kbd> on a US keyboard.
109    /// Labeled <kbd>w</kbd> on an AZERTY (e.g., French) keyboard, and <kbd>y</kbd> on a
110    /// QWERTZ (e.g., German) keyboard.
111    KeyZ,
112    /// <kbd>-</kbd> on a US keyboard.
113    Minus,
114    /// <kbd>.</kbd> on a US keyboard.
115    Period,
116    /// <kbd>'</kbd> on a US keyboard.
117    Quote,
118    /// <kbd>;</kbd> on a US keyboard.
119    Semicolon,
120    /// <kbd>/</kbd> on a US keyboard.
121    Slash,
122    /// <kbd>Alt</kbd>, <kbd>Option</kbd>, or <kbd>⌥</kbd>.
123    AltLeft,
124    /// <kbd>Alt</kbd>, <kbd>Option</kbd>, or <kbd>⌥</kbd>.
125    /// This is labeled <kbd>AltGr</kbd> on many keyboard layouts.
126    AltRight,
127    /// <kbd>Backspace</kbd> or <kbd>⌫</kbd>.
128    /// Labeled <kbd>Delete</kbd> on Apple keyboards.
129    Backspace,
130    /// <kbd>CapsLock</kbd> or <kbd>⇪</kbd>
131    CapsLock,
132    /// The application context menu key, which is typically found between the right
133    /// <kbd>Super</kbd> key and the right <kbd>Control</kbd> key.
134    ContextMenu,
135    /// <kbd>Control</kbd> or <kbd>⌃</kbd>
136    ControlLeft,
137    /// <kbd>Control</kbd> or <kbd>⌃</kbd>
138    ControlRight,
139    /// <kbd>Enter</kbd> or <kbd>↵</kbd>. Labeled <kbd>Return</kbd> on Apple keyboards.
140    Enter,
141    /// The Windows, <kbd>⌘</kbd>, <kbd>Command</kbd>, or other OS symbol key.
142    SuperLeft,
143    /// The Windows, <kbd>⌘</kbd>, <kbd>Command</kbd>, or other OS symbol key.
144    SuperRight,
145    /// <kbd>Shift</kbd> or <kbd>⇧</kbd>
146    ShiftLeft,
147    /// <kbd>Shift</kbd> or <kbd>⇧</kbd>
148    ShiftRight,
149    /// <kbd> </kbd> (space)
150    Space,
151    /// <kbd>Tab</kbd> or <kbd>⇥</kbd>
152    Tab,
153    /// Japanese: <kbd>変</kbd> (henkan)
154    Convert,
155    /// Japanese: <kbd>カタカナ</kbd>/<kbd>ひらがな</kbd>/<kbd>ローマ字</kbd>
156    /// (katakana/hiragana/romaji)
157    KanaMode,
158    /// Korean: HangulMode <kbd>한/영</kbd> (han/yeong)
159    ///
160    /// Japanese (Mac keyboard): <kbd>か</kbd> (kana)
161    Lang1,
162    /// Korean: Hanja <kbd>한</kbd> (hanja)
163    ///
164    /// Japanese (Mac keyboard): <kbd>英</kbd> (eisu)
165    Lang2,
166    /// Japanese (word-processing keyboard): Katakana
167    Lang3,
168    /// Japanese (word-processing keyboard): Hiragana
169    Lang4,
170    /// Japanese (word-processing keyboard): Zenkaku/Hankaku
171    Lang5,
172    /// Japanese: <kbd>無変換</kbd> (muhenkan)
173    NonConvert,
174    /// <kbd>⌦</kbd>. The forward delete key.
175    /// Note that on Apple keyboards, the key labelled <kbd>Delete</kbd> on the main part of
176    /// the keyboard is encoded as [`Backspace`].
177    ///
178    /// [`Backspace`]: Self::Backspace
179    Delete,
180    /// <kbd>Page Down</kbd>, <kbd>End</kbd>, or <kbd>↘</kbd>
181    End,
182    /// <kbd>Help</kbd>. Not present on standard PC keyboards.
183    Help,
184    /// <kbd>Home</kbd> or <kbd>↖</kbd>
185    Home,
186    /// <kbd>Insert</kbd> or <kbd>Ins</kbd>. Not present on Apple keyboards.
187    Insert,
188    /// <kbd>Page Down</kbd>, <kbd>PgDn</kbd>, or <kbd>⇟</kbd>
189    PageDown,
190    /// <kbd>Page Up</kbd>, <kbd>PgUp</kbd>, or <kbd>⇞</kbd>
191    PageUp,
192    /// <kbd>↓</kbd>
193    ArrowDown,
194    /// <kbd>←</kbd>
195    ArrowLeft,
196    /// <kbd>→</kbd>
197    ArrowRight,
198    /// <kbd>↑</kbd>
199    ArrowUp,
200    /// On the Mac, this is used for the numpad <kbd>Clear</kbd> key.
201    NumLock,
202    /// <kbd>0 Ins</kbd> on a keyboard. <kbd>0</kbd> on a phone or remote control
203    Numpad0,
204    /// <kbd>1 End</kbd> on a keyboard. <kbd>1</kbd> or <kbd>1 QZ</kbd> on a phone or remote
205    /// control
206    Numpad1,
207    /// <kbd>2 ↓</kbd> on a keyboard. <kbd>2 ABC</kbd> on a phone or remote control
208    Numpad2,
209    /// <kbd>3 PgDn</kbd> on a keyboard. <kbd>3 DEF</kbd> on a phone or remote control
210    Numpad3,
211    /// <kbd>4 ←</kbd> on a keyboard. <kbd>4 GHI</kbd> on a phone or remote control
212    Numpad4,
213    /// <kbd>5</kbd> on a keyboard. <kbd>5 JKL</kbd> on a phone or remote control
214    Numpad5,
215    /// <kbd>6 →</kbd> on a keyboard. <kbd>6 MNO</kbd> on a phone or remote control
216    Numpad6,
217    /// <kbd>7 Home</kbd> on a keyboard. <kbd>7 PQRS</kbd> or <kbd>7 PRS</kbd> on a phone
218    /// or remote control
219    Numpad7,
220    /// <kbd>8 ↑</kbd> on a keyboard. <kbd>8 TUV</kbd> on a phone or remote control
221    Numpad8,
222    /// <kbd>9 PgUp</kbd> on a keyboard. <kbd>9 WXYZ</kbd> or <kbd>9 WXY</kbd> on a phone
223    /// or remote control
224    Numpad9,
225    /// <kbd>+</kbd>
226    NumpadAdd,
227    /// Found on the Microsoft Natural Keyboard.
228    NumpadBackspace,
229    /// <kbd>C</kbd> or <kbd>A</kbd> (All Clear). Also for use with numpads that have a
230    /// <kbd>Clear</kbd> key that is separate from the <kbd>NumLock</kbd> key. On the Mac, the
231    /// numpad <kbd>Clear</kbd> key is encoded as [`NumLock`].
232    ///
233    /// [`NumLock`]: Self::NumLock
234    NumpadClear,
235    /// <kbd>C</kbd> (Clear Entry)
236    NumpadClearEntry,
237    /// <kbd>,</kbd> (thousands separator). For locales where the thousands separator
238    /// is a "." (e.g., Brazil), this key may generate a <kbd>.</kbd>.
239    NumpadComma,
240    /// <kbd>. Del</kbd>. For locales where the decimal separator is "," (e.g.,
241    /// Brazil), this key may generate a <kbd>,</kbd>.
242    NumpadDecimal,
243    /// <kbd>/</kbd>
244    NumpadDivide,
245    NumpadEnter,
246    /// <kbd>=</kbd>
247    NumpadEqual,
248    /// <kbd>#</kbd> on a phone or remote control device. This key is typically found
249    /// below the <kbd>9</kbd> key and to the right of the <kbd>0</kbd> key.
250    NumpadHash,
251    /// <kbd>M</kbd> Add current entry to the value stored in memory.
252    NumpadMemoryAdd,
253    /// <kbd>M</kbd> Clear the value stored in memory.
254    NumpadMemoryClear,
255    /// <kbd>M</kbd> Replace the current entry with the value stored in memory.
256    NumpadMemoryRecall,
257    /// <kbd>M</kbd> Replace the value stored in memory with the current entry.
258    NumpadMemoryStore,
259    /// <kbd>M</kbd> Subtract current entry from the value stored in memory.
260    NumpadMemorySubtract,
261    /// <kbd>*</kbd> on a keyboard. For use with numpads that provide mathematical
262    /// operations (<kbd>+</kbd>, <kbd>-</kbd> <kbd>*</kbd> and <kbd>/</kbd>).
263    ///
264    /// Use `NumpadStar` for the <kbd>*</kbd> key on phones and remote controls.
265    NumpadMultiply,
266    /// <kbd>(</kbd> Found on the Microsoft Natural Keyboard.
267    NumpadParenLeft,
268    /// <kbd>)</kbd> Found on the Microsoft Natural Keyboard.
269    NumpadParenRight,
270    /// <kbd>*</kbd> on a phone or remote control device.
271    ///
272    /// This key is typically found below the <kbd>7</kbd> key and to the left of
273    /// the <kbd>0</kbd> key.
274    ///
275    /// Use <kbd>"NumpadMultiply"</kbd> for the <kbd>*</kbd> key on
276    /// numeric keypads.
277    NumpadStar,
278    /// <kbd>-</kbd>
279    NumpadSubtract,
280    /// <kbd>Esc</kbd> or <kbd>⎋</kbd>
281    Escape,
282    /// <kbd>Fn</kbd> This is typically a hardware key that does not generate a separate code.
283    Fn,
284    /// <kbd>FLock</kbd> or <kbd>FnLock</kbd>. Function Lock key. Found on the Microsoft
285    /// Natural Keyboard.
286    FnLock,
287    /// <kbd>PrtScr SysRq</kbd> or <kbd>Print Screen</kbd>
288    PrintScreen,
289    /// <kbd>Scroll Lock</kbd>
290    ScrollLock,
291    /// <kbd>Pause Break</kbd>
292    Pause,
293    /// Some laptops place this key to the left of the <kbd>↑</kbd> key.
294    ///
295    /// This also the "back" button (triangle) on Android.
296    BrowserBack,
297    BrowserFavorites,
298    /// Some laptops place this key to the right of the <kbd>↑</kbd> key.
299    BrowserForward,
300    /// The "home" button on Android.
301    BrowserHome,
302    BrowserRefresh,
303    BrowserSearch,
304    BrowserStop,
305    /// <kbd>Eject</kbd> or <kbd>⏏</kbd>. This key is placed in the function section on some Apple
306    /// keyboards.
307    Eject,
308    /// Sometimes labelled <kbd>My Computer</kbd> on the keyboard
309    LaunchApp1,
310    /// Sometimes labelled <kbd>Calculator</kbd> on the keyboard
311    LaunchApp2,
312    LaunchMail,
313    MediaPlayPause,
314    MediaSelect,
315    MediaStop,
316    MediaTrackNext,
317    MediaTrackPrevious,
318    /// This key is placed in the function section on some Apple keyboards, replacing the
319    /// <kbd>Eject</kbd> key.
320    Power,
321    Sleep,
322    AudioVolumeDown,
323    AudioVolumeMute,
324    AudioVolumeUp,
325    WakeUp,
326    // Legacy modifier key. Also called "Super" in certain places.
327    Meta,
328    // Legacy modifier key.
329    Hyper,
330    Turbo,
331    Abort,
332    Resume,
333    Suspend,
334    /// Found on Sun’s USB keyboard.
335    Again,
336    /// Found on Sun’s USB keyboard.
337    Copy,
338    /// Found on Sun’s USB keyboard.
339    Cut,
340    /// Found on Sun’s USB keyboard.
341    Find,
342    /// Found on Sun’s USB keyboard.
343    Open,
344    /// Found on Sun’s USB keyboard.
345    Paste,
346    /// Found on Sun’s USB keyboard.
347    Props,
348    /// Found on Sun’s USB keyboard.
349    Select,
350    /// Found on Sun’s USB keyboard.
351    Undo,
352    /// Use for dedicated <kbd>ひらがな</kbd> key found on some Japanese word processing keyboards.
353    Hiragana,
354    /// Use for dedicated <kbd>カタカナ</kbd> key found on some Japanese word processing keyboards.
355    Katakana,
356    /// General-purpose function key.
357    /// Usually found at the top of the keyboard.
358    F1,
359    /// General-purpose function key.
360    /// Usually found at the top of the keyboard.
361    F2,
362    /// General-purpose function key.
363    /// Usually found at the top of the keyboard.
364    F3,
365    /// General-purpose function key.
366    /// Usually found at the top of the keyboard.
367    F4,
368    /// General-purpose function key.
369    /// Usually found at the top of the keyboard.
370    F5,
371    /// General-purpose function key.
372    /// Usually found at the top of the keyboard.
373    F6,
374    /// General-purpose function key.
375    /// Usually found at the top of the keyboard.
376    F7,
377    /// General-purpose function key.
378    /// Usually found at the top of the keyboard.
379    F8,
380    /// General-purpose function key.
381    /// Usually found at the top of the keyboard.
382    F9,
383    /// General-purpose function key.
384    /// Usually found at the top of the keyboard.
385    F10,
386    /// General-purpose function key.
387    /// Usually found at the top of the keyboard.
388    F11,
389    /// General-purpose function key.
390    /// Usually found at the top of the keyboard.
391    F12,
392    /// General-purpose function key.
393    /// Usually found at the top of the keyboard.
394    F13,
395    /// General-purpose function key.
396    /// Usually found at the top of the keyboard.
397    F14,
398    /// General-purpose function key.
399    /// Usually found at the top of the keyboard.
400    F15,
401    /// General-purpose function key.
402    /// Usually found at the top of the keyboard.
403    F16,
404    /// General-purpose function key.
405    /// Usually found at the top of the keyboard.
406    F17,
407    /// General-purpose function key.
408    /// Usually found at the top of the keyboard.
409    F18,
410    /// General-purpose function key.
411    /// Usually found at the top of the keyboard.
412    F19,
413    /// General-purpose function key.
414    /// Usually found at the top of the keyboard.
415    F20,
416    /// General-purpose function key.
417    /// Usually found at the top of the keyboard.
418    F21,
419    /// General-purpose function key.
420    /// Usually found at the top of the keyboard.
421    F22,
422    /// General-purpose function key.
423    /// Usually found at the top of the keyboard.
424    F23,
425    /// General-purpose function key.
426    /// Usually found at the top of the keyboard.
427    F24,
428    /// General-purpose function key.
429    F25,
430    /// General-purpose function key.
431    F26,
432    /// General-purpose function key.
433    F27,
434    /// General-purpose function key.
435    F28,
436    /// General-purpose function key.
437    F29,
438    /// General-purpose function key.
439    F30,
440    /// General-purpose function key.
441    F31,
442    /// General-purpose function key.
443    F32,
444    /// General-purpose function key.
445    F33,
446    /// General-purpose function key.
447    F34,
448    /// General-purpose function key.
449    F35,
450
451    Unknown,
452}