Skip to main content

zmk_studio_api/
keycode.rs

1use num_enum::TryFromPrimitive;
2use strum_macros::{AsRefStr, EnumIter, EnumString, IntoStaticStr};
3
4/// ZMK keycode value
5///
6/// This is the primary key type used by typed behavior APIs.
7#[derive(
8    Debug,
9    Clone,
10    Copy,
11    PartialEq,
12    Eq,
13    Hash,
14    TryFromPrimitive,
15    AsRefStr,
16    EnumString,
17    IntoStaticStr,
18    EnumIter,
19)]
20#[repr(u32)]
21#[allow(non_camel_case_types)]
22pub enum Keycode {
23    #[strum(serialize = "SYS_PWR")]
24    SYSTEM_POWER = 0x00010081,
25    #[strum(serialize = "SYS_SLEEP")]
26    SYSTEM_SLEEP = 0x00010082,
27    #[strum(serialize = "SYS_WAKE")]
28    SYSTEM_WAKE_UP = 0x00010083,
29    A = 0x00070004,
30    B = 0x00070005,
31    C = 0x00070006,
32    D = 0x00070007,
33    E = 0x00070008,
34    F = 0x00070009,
35    G = 0x0007000A,
36    H = 0x0007000B,
37    I = 0x0007000C,
38    J = 0x0007000D,
39    K = 0x0007000E,
40    L = 0x0007000F,
41    M = 0x00070010,
42    N = 0x00070011,
43    O = 0x00070012,
44    P = 0x00070013,
45    Q = 0x00070014,
46    R = 0x00070015,
47    S = 0x00070016,
48    T = 0x00070017,
49    U = 0x00070018,
50    V = 0x00070019,
51    W = 0x0007001A,
52    X = 0x0007001B,
53    Y = 0x0007001C,
54    Z = 0x0007001D,
55    #[strum(serialize = "N1")]
56    #[strum(serialize = "NUM_1")]
57    NUMBER_1 = 0x0007001E,
58    #[strum(serialize = "N2")]
59    #[strum(serialize = "NUM_2")]
60    NUMBER_2 = 0x0007001F,
61    #[strum(serialize = "N3")]
62    #[strum(serialize = "NUM_3")]
63    NUMBER_3 = 0x00070020,
64    #[strum(serialize = "N4")]
65    #[strum(serialize = "NUM_4")]
66    NUMBER_4 = 0x00070021,
67    #[strum(serialize = "N5")]
68    #[strum(serialize = "NUM_5")]
69    NUMBER_5 = 0x00070022,
70    #[strum(serialize = "N6")]
71    #[strum(serialize = "NUM_6")]
72    NUMBER_6 = 0x00070023,
73    #[strum(serialize = "N7")]
74    #[strum(serialize = "NUM_7")]
75    NUMBER_7 = 0x00070024,
76    #[strum(serialize = "N8")]
77    #[strum(serialize = "NUM_8")]
78    NUMBER_8 = 0x00070025,
79    #[strum(serialize = "N9")]
80    #[strum(serialize = "NUM_9")]
81    NUMBER_9 = 0x00070026,
82    #[strum(serialize = "N0")]
83    #[strum(serialize = "NUM_0")]
84    NUMBER_0 = 0x00070027,
85    #[strum(serialize = "ENTER")]
86    #[strum(serialize = "RET")]
87    RETURN = 0x00070028,
88    #[strum(serialize = "ESC")]
89    ESCAPE = 0x00070029,
90    #[strum(serialize = "BKSP")]
91    #[strum(serialize = "BSPC")]
92    BACKSPACE = 0x0007002A,
93    TAB = 0x0007002B,
94    #[strum(serialize = "SPC")]
95    SPACE = 0x0007002C,
96    MINUS = 0x0007002D,
97    #[strum(serialize = "EQL")]
98    EQUAL = 0x0007002E,
99    #[strum(serialize = "BSLH")]
100    BACKSLASH = 0x00070031,
101    #[strum(serialize = "NUHS")]
102    NON_US_HASH = 0x00070032,
103    #[strum(serialize = "SCLN")]
104    #[strum(serialize = "SEMI")]
105    SEMICOLON = 0x00070033,
106    #[strum(serialize = "APOS")]
107    #[strum(serialize = "APOSTROPHE")]
108    #[strum(serialize = "QUOT")]
109    #[strum(serialize = "SQT")]
110    SINGLE_QUOTE = 0x00070034,
111    #[strum(serialize = "GRAV")]
112    GRAVE = 0x00070035,
113    #[strum(serialize = "CMMA")]
114    COMMA = 0x00070036,
115    #[strum(serialize = "DOT")]
116    PERIOD = 0x00070037,
117    #[strum(serialize = "FSLH")]
118    SLASH = 0x00070038,
119    #[strum(serialize = "CAPS")]
120    #[strum(serialize = "CLCK")]
121    CAPSLOCK = 0x00070039,
122    F1 = 0x0007003A,
123    F2 = 0x0007003B,
124    F3 = 0x0007003C,
125    F4 = 0x0007003D,
126    F5 = 0x0007003E,
127    F6 = 0x0007003F,
128    F7 = 0x00070040,
129    F8 = 0x00070041,
130    F9 = 0x00070042,
131    F10 = 0x00070043,
132    F11 = 0x00070044,
133    F12 = 0x00070045,
134    #[strum(serialize = "PRSC")]
135    #[strum(serialize = "PSCRN")]
136    PRINTSCREEN = 0x00070046,
137    #[strum(serialize = "SCLK")]
138    #[strum(serialize = "SLCK")]
139    SCROLLLOCK = 0x00070047,
140    #[strum(serialize = "PAUS")]
141    PAUSE_BREAK = 0x00070048,
142    #[strum(serialize = "INS")]
143    INSERT = 0x00070049,
144    HOME = 0x0007004A,
145    #[strum(serialize = "PG_UP")]
146    #[strum(serialize = "PGUP")]
147    PAGE_UP = 0x0007004B,
148    #[strum(serialize = "DEL")]
149    DELETE = 0x0007004C,
150    END = 0x0007004D,
151    #[strum(serialize = "PG_DN")]
152    #[strum(serialize = "PGDN")]
153    PAGE_DOWN = 0x0007004E,
154    #[strum(serialize = "RARW")]
155    #[strum(serialize = "RIGHT")]
156    RIGHT_ARROW = 0x0007004F,
157    #[strum(serialize = "LARW")]
158    #[strum(serialize = "LEFT")]
159    LEFT_ARROW = 0x00070050,
160    #[strum(serialize = "DARW")]
161    #[strum(serialize = "DOWN")]
162    DOWN_ARROW = 0x00070051,
163    #[strum(serialize = "UARW")]
164    #[strum(serialize = "UP")]
165    UP_ARROW = 0x00070052,
166    #[strum(serialize = "KP_NLCK")]
167    #[strum(serialize = "KP_NUM")]
168    KP_NUMLOCK = 0x00070053,
169    #[strum(serialize = "KDIV")]
170    #[strum(serialize = "KP_SLASH")]
171    KP_DIVIDE = 0x00070054,
172    #[strum(serialize = "KMLT")]
173    #[strum(serialize = "KP_MULTIPLY")]
174    KP_ASTERISK = 0x00070055,
175    #[strum(serialize = "KMIN")]
176    #[strum(serialize = "KP_MINUS")]
177    KP_SUBTRACT = 0x00070056,
178    #[strum(serialize = "KPLS")]
179    KP_PLUS = 0x00070057,
180    KP_ENTER = 0x00070058,
181    #[strum(serialize = "KP_N1")]
182    KP_NUMBER_1 = 0x00070059,
183    #[strum(serialize = "KP_N2")]
184    KP_NUMBER_2 = 0x0007005A,
185    #[strum(serialize = "KP_N3")]
186    KP_NUMBER_3 = 0x0007005B,
187    #[strum(serialize = "KP_N4")]
188    KP_NUMBER_4 = 0x0007005C,
189    #[strum(serialize = "KP_N5")]
190    KP_NUMBER_5 = 0x0007005D,
191    #[strum(serialize = "KP_N6")]
192    KP_NUMBER_6 = 0x0007005E,
193    #[strum(serialize = "KP_N7")]
194    KP_NUMBER_7 = 0x0007005F,
195    #[strum(serialize = "KP_N8")]
196    KP_NUMBER_8 = 0x00070060,
197    #[strum(serialize = "KP_N9")]
198    KP_NUMBER_9 = 0x00070061,
199    #[strum(serialize = "KP_N0")]
200    KP_NUMBER_0 = 0x00070062,
201    KP_DOT = 0x00070063,
202    #[strum(serialize = "GUI")]
203    #[strum(serialize = "K_APP")]
204    #[strum(serialize = "K_APPLICATION")]
205    #[strum(serialize = "K_CMENU")]
206    K_CONTEXT_MENU = 0x00070065,
207    #[strum(serialize = "K_PWR")]
208    K_POWER = 0x00070066,
209    KP_EQUAL = 0x00070067,
210    F13 = 0x00070068,
211    F14 = 0x00070069,
212    F15 = 0x0007006A,
213    F16 = 0x0007006B,
214    F17 = 0x0007006C,
215    F18 = 0x0007006D,
216    F19 = 0x0007006E,
217    F20 = 0x0007006F,
218    F21 = 0x00070070,
219    F22 = 0x00070071,
220    F23 = 0x00070072,
221    F24 = 0x00070073,
222    #[strum(serialize = "K_EXEC")]
223    K_EXECUTE = 0x00070074,
224    K_HELP = 0x00070075,
225    K_MENU = 0x00070076,
226    K_SELECT = 0x00070077,
227    K_STOP = 0x00070078,
228    #[strum(serialize = "K_REDO")]
229    K_AGAIN = 0x00070079,
230    #[strum(serialize = "UNDO")]
231    K_UNDO = 0x0007007A,
232    #[strum(serialize = "CUT")]
233    K_CUT = 0x0007007B,
234    #[strum(serialize = "COPY")]
235    K_COPY = 0x0007007C,
236    #[strum(serialize = "PSTE")]
237    K_PASTE = 0x0007007D,
238    K_FIND = 0x0007007E,
239    K_MUTE = 0x0007007F,
240    #[strum(serialize = "K_VOL_UP")]
241    #[strum(serialize = "VOLU")]
242    K_VOLUME_UP = 0x00070080,
243    #[strum(serialize = "K_VOL_DN")]
244    #[strum(serialize = "VOLD")]
245    K_VOLUME_DOWN = 0x00070081,
246    #[strum(serialize = "LCAPS")]
247    LOCKING_CAPS = 0x00070082,
248    #[strum(serialize = "LNLCK")]
249    LOCKING_NUM = 0x00070083,
250    #[strum(serialize = "LSLCK")]
251    LOCKING_SCROLL = 0x00070084,
252    KP_COMMA = 0x00070085,
253    KP_EQUAL_AS400 = 0x00070086,
254    #[strum(serialize = "INT_RO")]
255    #[strum(serialize = "INT1")]
256    INTERNATIONAL_1 = 0x00070087,
257    #[strum(serialize = "INT_KANA")]
258    #[strum(serialize = "INT2")]
259    #[strum(serialize = "INTERNATIONAL_2")]
260    INT_KATAKANAHIRAGANA = 0x00070088,
261    #[strum(serialize = "INT_YEN")]
262    #[strum(serialize = "INT3")]
263    INTERNATIONAL_3 = 0x00070089,
264    #[strum(serialize = "INT_HENKAN")]
265    #[strum(serialize = "INT4")]
266    INTERNATIONAL_4 = 0x0007008A,
267    #[strum(serialize = "INT_MUHENKAN")]
268    #[strum(serialize = "INT5")]
269    INTERNATIONAL_5 = 0x0007008B,
270    #[strum(serialize = "INT_KPJPCOMMA")]
271    #[strum(serialize = "INT6")]
272    INTERNATIONAL_6 = 0x0007008C,
273    #[strum(serialize = "INT7")]
274    INTERNATIONAL_7 = 0x0007008D,
275    #[strum(serialize = "INT8")]
276    INTERNATIONAL_8 = 0x0007008E,
277    #[strum(serialize = "INT9")]
278    INTERNATIONAL_9 = 0x0007008F,
279    #[strum(serialize = "LANG1")]
280    #[strum(serialize = "LANGUAGE_1")]
281    LANG_HANGEUL = 0x00070090,
282    #[strum(serialize = "LANG2")]
283    #[strum(serialize = "LANGUAGE_2")]
284    LANG_HANJA = 0x00070091,
285    #[strum(serialize = "LANG3")]
286    #[strum(serialize = "LANGUAGE_3")]
287    LANG_KATAKANA = 0x00070092,
288    #[strum(serialize = "LANG4")]
289    #[strum(serialize = "LANGUAGE_4")]
290    LANG_HIRAGANA = 0x00070093,
291    #[strum(serialize = "LANG5")]
292    #[strum(serialize = "LANGUAGE_5")]
293    LANG_ZENKAKUHANKAKU = 0x00070094,
294    #[strum(serialize = "LANG6")]
295    LANGUAGE_6 = 0x00070095,
296    #[strum(serialize = "LANG7")]
297    LANGUAGE_7 = 0x00070096,
298    #[strum(serialize = "LANG8")]
299    LANGUAGE_8 = 0x00070097,
300    #[strum(serialize = "LANG9")]
301    LANGUAGE_9 = 0x00070098,
302    ALT_ERASE = 0x00070099,
303    #[strum(serialize = "SYSREQ")]
304    ATTENTION = 0x0007009A,
305    K_CANCEL = 0x0007009B,
306    CLEAR = 0x0007009C,
307    PRIOR = 0x0007009D,
308    #[strum(serialize = "RET2")]
309    RETURN2 = 0x0007009E,
310    SEPARATOR = 0x0007009F,
311    OUT = 0x000700A0,
312    OPER = 0x000700A1,
313    CLEAR_AGAIN = 0x000700A2,
314    CRSEL = 0x000700A3,
315    EXSEL = 0x000700A4,
316    #[strum(serialize = "KP_LPAR")]
317    KP_LEFT_PARENTHESIS = 0x000700B6,
318    #[strum(serialize = "KP_RPAR")]
319    KP_RIGHT_PARENTHESIS = 0x000700B7,
320    KP_CLEAR = 0x000700D8,
321    #[strum(serialize = "LCTL")]
322    #[strum(serialize = "LCTRL")]
323    LEFT_CONTROL = 0x000700E0,
324    #[strum(serialize = "LSFT")]
325    #[strum(serialize = "LSHFT")]
326    #[strum(serialize = "LSHIFT")]
327    LEFT_SHIFT = 0x000700E1,
328    #[strum(serialize = "LALT")]
329    LEFT_ALT = 0x000700E2,
330    #[strum(serialize = "LCMD")]
331    #[strum(serialize = "LEFT_GUI")]
332    #[strum(serialize = "LEFT_META")]
333    #[strum(serialize = "LEFT_WIN")]
334    #[strum(serialize = "LGUI")]
335    #[strum(serialize = "LMETA")]
336    #[strum(serialize = "LWIN")]
337    LEFT_COMMAND = 0x000700E3,
338    #[strum(serialize = "RCTL")]
339    #[strum(serialize = "RCTRL")]
340    RIGHT_CONTROL = 0x000700E4,
341    #[strum(serialize = "RSFT")]
342    #[strum(serialize = "RSHFT")]
343    #[strum(serialize = "RSHIFT")]
344    RIGHT_SHIFT = 0x000700E5,
345    #[strum(serialize = "RALT")]
346    RIGHT_ALT = 0x000700E6,
347    #[strum(serialize = "RCMD")]
348    #[strum(serialize = "RGUI")]
349    #[strum(serialize = "RIGHT_GUI")]
350    #[strum(serialize = "RIGHT_META")]
351    #[strum(serialize = "RIGHT_WIN")]
352    #[strum(serialize = "RMETA")]
353    #[strum(serialize = "RWIN")]
354    RIGHT_COMMAND = 0x000700E7,
355    #[strum(serialize = "K_PP")]
356    K_PLAY_PAUSE = 0x000700E8,
357    K_STOP2 = 0x000700E9,
358    #[strum(serialize = "K_PREV")]
359    K_PREVIOUS = 0x000700EA,
360    K_NEXT = 0x000700EB,
361    K_EJECT = 0x000700EC,
362    #[strum(serialize = "K_VOL_UP2")]
363    K_VOLUME_UP2 = 0x000700ED,
364    #[strum(serialize = "K_VOL_DN2")]
365    K_VOLUME_DOWN2 = 0x000700EE,
366    K_MUTE2 = 0x000700EF,
367    K_WWW = 0x000700F0,
368    K_BACK = 0x000700F1,
369    K_FORWARD = 0x000700F2,
370    K_STOP3 = 0x000700F3,
371    K_FIND2 = 0x000700F4,
372    K_SCROLL_UP = 0x000700F5,
373    K_SCROLL_DOWN = 0x000700F6,
374    K_EDIT = 0x000700F7,
375    K_SLEEP = 0x000700F8,
376    #[strum(serialize = "K_COFFEE")]
377    #[strum(serialize = "K_LOCK")]
378    K_SCREENSAVER = 0x000700F9,
379    K_REFRESH = 0x000700FA,
380    #[strum(serialize = "K_CALC")]
381    K_CALCULATOR = 0x000700FB,
382    #[strum(serialize = "C_PWR")]
383    C_POWER = 0x000C0030,
384    C_RESET = 0x000C0031,
385    C_SLEEP = 0x000C0032,
386    C_SLEEP_MODE = 0x000C0034,
387    C_MENU = 0x000C0040,
388    #[strum(serialize = "C_MENU_PICK")]
389    C_MENU_SELECT = 0x000C0041,
390    C_MENU_UP = 0x000C0042,
391    C_MENU_DOWN = 0x000C0043,
392    C_MENU_LEFT = 0x000C0044,
393    C_MENU_RIGHT = 0x000C0045,
394    #[strum(serialize = "C_MENU_ESC")]
395    C_MENU_ESCAPE = 0x000C0046,
396    #[strum(serialize = "C_MENU_INC")]
397    C_MENU_INCREASE = 0x000C0047,
398    #[strum(serialize = "C_MENU_DEC")]
399    C_MENU_DECREASE = 0x000C0048,
400    C_DATA_ON_SCREEN = 0x000C0060,
401    #[strum(serialize = "C_CAPTIONS")]
402    C_SUBTITLES = 0x000C0061,
403    C_SNAPSHOT = 0x000C0065,
404    C_PIP = 0x000C0067,
405    #[strum(serialize = "C_RED")]
406    C_RED_BUTTON = 0x000C0069,
407    #[strum(serialize = "C_GREEN")]
408    C_GREEN_BUTTON = 0x000C006A,
409    #[strum(serialize = "C_BLUE")]
410    C_BLUE_BUTTON = 0x000C006B,
411    #[strum(serialize = "C_YELLOW")]
412    C_YELLOW_BUTTON = 0x000C006C,
413    C_ASPECT = 0x000C006D,
414    #[strum(serialize = "C_MODE_STEP")]
415    C_MEDIA_STEP = 0x000C0082,
416    #[strum(serialize = "C_CHAN_LAST")]
417    C_RECALL_LAST = 0x000C0083,
418    C_MEDIA_TV = 0x000C0089,
419    C_MEDIA_WWW = 0x000C008A,
420    C_MEDIA_DVD = 0x000C008B,
421    C_MEDIA_PHONE = 0x000C008C,
422    C_MEDIA_GAMES = 0x000C008F,
423    C_MEDIA_CD = 0x000C0091,
424    C_MEDIA_VCR = 0x000C0092,
425    C_MEDIA_TUNER = 0x000C0093,
426    C_QUIT = 0x000C0094,
427    C_HELP = 0x000C0095,
428    C_MEDIA_TAPE = 0x000C0096,
429    C_MEDIA_CABLE = 0x000C0097,
430    C_MEDIA_HOME = 0x000C009A,
431    #[strum(serialize = "C_CHAN_INC")]
432    C_CHANNEL_INC = 0x000C009C,
433    #[strum(serialize = "C_CHAN_DEC")]
434    C_CHANNEL_DEC = 0x000C009D,
435    C_MEDIA_VCR_PLUS = 0x000C00A0,
436    C_PLAY = 0x000C00B0,
437    C_PAUSE = 0x000C00B1,
438    #[strum(serialize = "C_REC")]
439    C_RECORD = 0x000C00B2,
440    #[strum(serialize = "C_FF")]
441    C_FAST_FORWARD = 0x000C00B3,
442    #[strum(serialize = "C_RW")]
443    C_REWIND = 0x000C00B4,
444    #[strum(serialize = "M_NEXT")]
445    C_NEXT = 0x000C00B5,
446    #[strum(serialize = "C_PREV")]
447    #[strum(serialize = "M_PREV")]
448    C_PREVIOUS = 0x000C00B6,
449    #[strum(serialize = "M_STOP")]
450    C_STOP = 0x000C00B7,
451    #[strum(serialize = "M_EJCT")]
452    C_EJECT = 0x000C00B8,
453    #[strum(serialize = "C_SHUFFLE")]
454    C_RANDOM_PLAY = 0x000C00B9,
455    C_REPEAT = 0x000C00BC,
456    #[strum(serialize = "C_SLOW2")]
457    C_SLOW_TRACKING = 0x000C00BF,
458    C_STOP_EJECT = 0x000C00CC,
459    #[strum(serialize = "C_PP")]
460    #[strum(serialize = "M_PLAY")]
461    C_PLAY_PAUSE = 0x000C00CD,
462    C_VOICE_COMMAND = 0x000C00CF,
463    #[strum(serialize = "M_MUTE")]
464    C_MUTE = 0x000C00E2,
465    C_BASS_BOOST = 0x000C00E5,
466    #[strum(serialize = "C_VOL_UP")]
467    #[strum(serialize = "M_VOLU")]
468    C_VOLUME_UP = 0x000C00E9,
469    #[strum(serialize = "C_VOL_DN")]
470    #[strum(serialize = "M_VOLD")]
471    C_VOLUME_DOWN = 0x000C00EA,
472    C_SLOW = 0x000C00F5,
473    C_AL_WORD = 0x000C0184,
474    C_AL_TEXT_EDITOR = 0x000C0185,
475    #[strum(serialize = "C_AL_SHEET")]
476    C_AL_SPREADSHEET = 0x000C0186,
477    #[strum(serialize = "C_AL_DB")]
478    C_AL_DATABASE = 0x000C0189,
479    #[strum(serialize = "C_AL_MAIL")]
480    C_AL_EMAIL = 0x000C018A,
481    C_AL_NEWS = 0x000C018B,
482    C_AL_VOICEMAIL = 0x000C018C,
483    #[strum(serialize = "C_AL_CAL")]
484    C_AL_CALENDAR = 0x000C018E,
485    C_AL_JOURNAL = 0x000C0190,
486    C_AL_FINANCE = 0x000C0191,
487    #[strum(serialize = "C_AL_CALC")]
488    C_AL_CALCULATOR = 0x000C0192,
489    C_AL_WWW = 0x000C0196,
490    #[strum(serialize = "C_AL_CHAT")]
491    C_AL_NETWORK_CHAT = 0x000C0199,
492    C_AL_LOGOFF = 0x000C019C,
493    C_AL_CONTROL_PANEL = 0x000C019F,
494    C_AL_HELP = 0x000C01A6,
495    #[strum(serialize = "C_AL_DOCS")]
496    C_AL_DOCUMENTS = 0x000C01A7,
497    #[strum(serialize = "C_AL_SPELL")]
498    C_AL_SPELLCHECK = 0x000C01AB,
499    C_AL_SCREEN_SAVER = 0x000C01B1,
500    #[strum(serialize = "C_AL_FILES")]
501    C_AL_FILE_BROWSER = 0x000C01B4,
502    #[strum(serialize = "C_AL_IMAGES")]
503    C_AL_IMAGE_BROWSER = 0x000C01B6,
504    #[strum(serialize = "C_AL_AUDIO")]
505    #[strum(serialize = "C_AL_MUSIC")]
506    C_AL_AUDIO_BROWSER = 0x000C01B7,
507    #[strum(serialize = "C_AL_MOVIES")]
508    C_AL_MOVIE_BROWSER = 0x000C01B8,
509    C_AC_NEW = 0x000C0201,
510    C_AC_OPEN = 0x000C0202,
511    C_AC_CLOSE = 0x000C0203,
512    C_AC_EXIT = 0x000C0204,
513    C_AC_SAVE = 0x000C0207,
514    C_AC_PRINT = 0x000C0208,
515    #[strum(serialize = "C_AC_PROPS")]
516    C_AC_PROPERTIES = 0x000C0209,
517    C_AC_UNDO = 0x000C021A,
518    C_AC_COPY = 0x000C021B,
519    C_AC_CUT = 0x000C021C,
520    C_AC_PASTE = 0x000C021D,
521    C_AC_FIND = 0x000C021F,
522    C_AC_SEARCH = 0x000C0221,
523    C_AC_GOTO = 0x000C0222,
524    C_AC_HOME = 0x000C0223,
525    C_AC_BACK = 0x000C0224,
526    C_AC_FORWARD = 0x000C0225,
527    C_AC_STOP = 0x000C0226,
528    C_AC_REFRESH = 0x000C0227,
529    #[strum(serialize = "C_AC_BOOKMARKS")]
530    #[strum(serialize = "C_AC_FAVORITES")]
531    C_AC_FAVOURITES = 0x000C022A,
532    C_AC_ZOOM_IN = 0x000C022D,
533    C_AC_ZOOM_OUT = 0x000C022E,
534    C_AC_ZOOM = 0x000C022F,
535    C_AC_VIEW_TOGGLE = 0x000C0232,
536    C_AC_SCROLL_UP = 0x000C0233,
537    C_AC_SCROLL_DOWN = 0x000C0234,
538    C_AC_EDIT = 0x000C023D,
539    C_AC_CANCEL = 0x000C025F,
540    #[strum(serialize = "C_AC_INS")]
541    C_AC_INSERT = 0x000C0269,
542    C_AC_DEL = 0x000C026A,
543    C_AC_REDO = 0x000C0279,
544    C_AC_REPLY = 0x000C0289,
545    C_AC_FORWARD_MAIL = 0x000C028B,
546    C_AC_SEND = 0x000C028C,
547    #[strum(serialize = "GLOBE")]
548    C_AC_NEXT_KEYBOARD_LAYOUT_SELECT = 0x000C029D,
549    #[strum(serialize = "BANG")]
550    #[strum(serialize = "EXCL")]
551    EXCLAMATION = 0x0207001E,
552    #[strum(serialize = "AT")]
553    #[strum(serialize = "ATSN")]
554    AT_SIGN = 0x0207001F,
555    #[strum(serialize = "HASH")]
556    POUND = 0x02070020,
557    #[strum(serialize = "DLLR")]
558    DOLLAR = 0x02070021,
559    #[strum(serialize = "PRCNT")]
560    #[strum(serialize = "PRCT")]
561    PERCENT = 0x02070022,
562    #[strum(serialize = "CRRT")]
563    CARET = 0x02070023,
564    #[strum(serialize = "AMPS")]
565    AMPERSAND = 0x02070024,
566    #[strum(serialize = "ASTRK")]
567    #[strum(serialize = "STAR")]
568    ASTERISK = 0x02070025,
569    #[strum(serialize = "UNDER")]
570    UNDERSCORE = 0x0207002D,
571    PLUS = 0x0207002E,
572    PIPE = 0x02070031,
573    TILDE2 = 0x02070032,
574    #[strum(serialize = "COLN")]
575    COLON = 0x02070033,
576    #[strum(serialize = "TILD")]
577    TILDE = 0x02070035,
578    #[strum(serialize = "LABT")]
579    #[strum(serialize = "LT")]
580    LESS_THAN = 0x02070036,
581    #[strum(serialize = "QMARK")]
582    QUESTION = 0x02070038,
583    CLEAR2 = 0x02070053,
584    PIPE2 = 0x02070064,
585}
586
587impl Keycode {
588    /// Returns the raw HID usage value as encoded by ZMK.
589    pub const fn to_hid_usage(self) -> u32 {
590        self as u32
591    }
592
593    /// Converts a raw HID usage value into a known [`Keycode`].
594    ///
595    /// Returns `None` when the usage is not present in this enum table.
596    pub fn from_hid_usage(encoded: u32) -> Option<Self> {
597        Self::try_from(encoded).ok()
598    }
599
600    /// Parses a keycode from a ZMK name/alias (for example `"A"` or `"LSHFT"`).
601    pub fn from_name(name: &str) -> Option<Self> {
602        name.parse().ok()
603    }
604
605    /// Returns the canonical static name for this keycode variant.
606    pub fn to_name(self) -> &'static str {
607        <&'static str>::from(self)
608    }
609}