viewpoint_core/page/keyboard/keys/
mod.rs

1//! Key definitions for keyboard input.
2//!
3//! This module contains the key definition struct and the large match statement
4//! for mapping key names to their CDP properties.
5
6/// Key definition with all required properties for CDP.
7#[derive(Debug, Clone)]
8pub struct KeyDefinition {
9    /// The key code (e.g., "`KeyA`", "Enter").
10    pub code: &'static str,
11    /// The key value (e.g., "a", "Enter").
12    pub key: &'static str,
13    /// Windows virtual key code.
14    pub key_code: i32,
15    /// The text generated by this key (if any).
16    pub text: Option<&'static str>,
17    /// Whether this key is on the keypad.
18    pub is_keypad: bool,
19    /// The location of the key (0 = standard, 1 = left, 2 = right, 3 = numpad).
20    pub location: i32,
21}
22
23/// Get the key definition for a given key name.
24pub fn get_key_definition(key: &str) -> Option<KeyDefinition> {
25    Some(match key {
26        // Modifier keys
27        "Alt" | "AltLeft" => KeyDefinition {
28            code: "AltLeft",
29            key: "Alt",
30            key_code: 18,
31            text: None,
32            is_keypad: false,
33            location: 1,
34        },
35        "AltRight" => KeyDefinition {
36            code: "AltRight",
37            key: "Alt",
38            key_code: 18,
39            text: None,
40            is_keypad: false,
41            location: 2,
42        },
43        "Control" | "ControlLeft" => KeyDefinition {
44            code: "ControlLeft",
45            key: "Control",
46            key_code: 17,
47            text: None,
48            is_keypad: false,
49            location: 1,
50        },
51        "ControlRight" => KeyDefinition {
52            code: "ControlRight",
53            key: "Control",
54            key_code: 17,
55            text: None,
56            is_keypad: false,
57            location: 2,
58        },
59        "Meta" | "MetaLeft" => KeyDefinition {
60            code: "MetaLeft",
61            key: "Meta",
62            key_code: 91,
63            text: None,
64            is_keypad: false,
65            location: 1,
66        },
67        "MetaRight" => KeyDefinition {
68            code: "MetaRight",
69            key: "Meta",
70            key_code: 92,
71            text: None,
72            is_keypad: false,
73            location: 2,
74        },
75        "Shift" | "ShiftLeft" => KeyDefinition {
76            code: "ShiftLeft",
77            key: "Shift",
78            key_code: 16,
79            text: None,
80            is_keypad: false,
81            location: 1,
82        },
83        "ShiftRight" => KeyDefinition {
84            code: "ShiftRight",
85            key: "Shift",
86            key_code: 16,
87            text: None,
88            is_keypad: false,
89            location: 2,
90        },
91
92        // Function keys
93        "F1" => KeyDefinition {
94            code: "F1",
95            key: "F1",
96            key_code: 112,
97            text: None,
98            is_keypad: false,
99            location: 0,
100        },
101        "F2" => KeyDefinition {
102            code: "F2",
103            key: "F2",
104            key_code: 113,
105            text: None,
106            is_keypad: false,
107            location: 0,
108        },
109        "F3" => KeyDefinition {
110            code: "F3",
111            key: "F3",
112            key_code: 114,
113            text: None,
114            is_keypad: false,
115            location: 0,
116        },
117        "F4" => KeyDefinition {
118            code: "F4",
119            key: "F4",
120            key_code: 115,
121            text: None,
122            is_keypad: false,
123            location: 0,
124        },
125        "F5" => KeyDefinition {
126            code: "F5",
127            key: "F5",
128            key_code: 116,
129            text: None,
130            is_keypad: false,
131            location: 0,
132        },
133        "F6" => KeyDefinition {
134            code: "F6",
135            key: "F6",
136            key_code: 117,
137            text: None,
138            is_keypad: false,
139            location: 0,
140        },
141        "F7" => KeyDefinition {
142            code: "F7",
143            key: "F7",
144            key_code: 118,
145            text: None,
146            is_keypad: false,
147            location: 0,
148        },
149        "F8" => KeyDefinition {
150            code: "F8",
151            key: "F8",
152            key_code: 119,
153            text: None,
154            is_keypad: false,
155            location: 0,
156        },
157        "F9" => KeyDefinition {
158            code: "F9",
159            key: "F9",
160            key_code: 120,
161            text: None,
162            is_keypad: false,
163            location: 0,
164        },
165        "F10" => KeyDefinition {
166            code: "F10",
167            key: "F10",
168            key_code: 121,
169            text: None,
170            is_keypad: false,
171            location: 0,
172        },
173        "F11" => KeyDefinition {
174            code: "F11",
175            key: "F11",
176            key_code: 122,
177            text: None,
178            is_keypad: false,
179            location: 0,
180        },
181        "F12" => KeyDefinition {
182            code: "F12",
183            key: "F12",
184            key_code: 123,
185            text: None,
186            is_keypad: false,
187            location: 0,
188        },
189
190        // Navigation keys
191        "ArrowDown" => KeyDefinition {
192            code: "ArrowDown",
193            key: "ArrowDown",
194            key_code: 40,
195            text: None,
196            is_keypad: false,
197            location: 0,
198        },
199        "ArrowLeft" => KeyDefinition {
200            code: "ArrowLeft",
201            key: "ArrowLeft",
202            key_code: 37,
203            text: None,
204            is_keypad: false,
205            location: 0,
206        },
207        "ArrowRight" => KeyDefinition {
208            code: "ArrowRight",
209            key: "ArrowRight",
210            key_code: 39,
211            text: None,
212            is_keypad: false,
213            location: 0,
214        },
215        "ArrowUp" => KeyDefinition {
216            code: "ArrowUp",
217            key: "ArrowUp",
218            key_code: 38,
219            text: None,
220            is_keypad: false,
221            location: 0,
222        },
223        "End" => KeyDefinition {
224            code: "End",
225            key: "End",
226            key_code: 35,
227            text: None,
228            is_keypad: false,
229            location: 0,
230        },
231        "Home" => KeyDefinition {
232            code: "Home",
233            key: "Home",
234            key_code: 36,
235            text: None,
236            is_keypad: false,
237            location: 0,
238        },
239        "PageDown" => KeyDefinition {
240            code: "PageDown",
241            key: "PageDown",
242            key_code: 34,
243            text: None,
244            is_keypad: false,
245            location: 0,
246        },
247        "PageUp" => KeyDefinition {
248            code: "PageUp",
249            key: "PageUp",
250            key_code: 33,
251            text: None,
252            is_keypad: false,
253            location: 0,
254        },
255
256        // Editing keys
257        "Backspace" => KeyDefinition {
258            code: "Backspace",
259            key: "Backspace",
260            key_code: 8,
261            text: None,
262            is_keypad: false,
263            location: 0,
264        },
265        "Delete" => KeyDefinition {
266            code: "Delete",
267            key: "Delete",
268            key_code: 46,
269            text: None,
270            is_keypad: false,
271            location: 0,
272        },
273        "Enter" => KeyDefinition {
274            code: "Enter",
275            key: "Enter",
276            key_code: 13,
277            text: Some("\r"),
278            is_keypad: false,
279            location: 0,
280        },
281        "NumpadEnter" => KeyDefinition {
282            code: "NumpadEnter",
283            key: "Enter",
284            key_code: 13,
285            text: Some("\r"),
286            is_keypad: true,
287            location: 3,
288        },
289        "Tab" => KeyDefinition {
290            code: "Tab",
291            key: "Tab",
292            key_code: 9,
293            text: None,
294            is_keypad: false,
295            location: 0,
296        },
297        "Escape" => KeyDefinition {
298            code: "Escape",
299            key: "Escape",
300            key_code: 27,
301            text: None,
302            is_keypad: false,
303            location: 0,
304        },
305        "Insert" => KeyDefinition {
306            code: "Insert",
307            key: "Insert",
308            key_code: 45,
309            text: None,
310            is_keypad: false,
311            location: 0,
312        },
313
314        // Whitespace
315        "Space" | " " => KeyDefinition {
316            code: "Space",
317            key: " ",
318            key_code: 32,
319            text: Some(" "),
320            is_keypad: false,
321            location: 0,
322        },
323
324        // Digit keys
325        "Digit0" | "0" => KeyDefinition {
326            code: "Digit0",
327            key: "0",
328            key_code: 48,
329            text: Some("0"),
330            is_keypad: false,
331            location: 0,
332        },
333        "Digit1" | "1" => KeyDefinition {
334            code: "Digit1",
335            key: "1",
336            key_code: 49,
337            text: Some("1"),
338            is_keypad: false,
339            location: 0,
340        },
341        "Digit2" | "2" => KeyDefinition {
342            code: "Digit2",
343            key: "2",
344            key_code: 50,
345            text: Some("2"),
346            is_keypad: false,
347            location: 0,
348        },
349        "Digit3" | "3" => KeyDefinition {
350            code: "Digit3",
351            key: "3",
352            key_code: 51,
353            text: Some("3"),
354            is_keypad: false,
355            location: 0,
356        },
357        "Digit4" | "4" => KeyDefinition {
358            code: "Digit4",
359            key: "4",
360            key_code: 52,
361            text: Some("4"),
362            is_keypad: false,
363            location: 0,
364        },
365        "Digit5" | "5" => KeyDefinition {
366            code: "Digit5",
367            key: "5",
368            key_code: 53,
369            text: Some("5"),
370            is_keypad: false,
371            location: 0,
372        },
373        "Digit6" | "6" => KeyDefinition {
374            code: "Digit6",
375            key: "6",
376            key_code: 54,
377            text: Some("6"),
378            is_keypad: false,
379            location: 0,
380        },
381        "Digit7" | "7" => KeyDefinition {
382            code: "Digit7",
383            key: "7",
384            key_code: 55,
385            text: Some("7"),
386            is_keypad: false,
387            location: 0,
388        },
389        "Digit8" | "8" => KeyDefinition {
390            code: "Digit8",
391            key: "8",
392            key_code: 56,
393            text: Some("8"),
394            is_keypad: false,
395            location: 0,
396        },
397        "Digit9" | "9" => KeyDefinition {
398            code: "Digit9",
399            key: "9",
400            key_code: 57,
401            text: Some("9"),
402            is_keypad: false,
403            location: 0,
404        },
405
406        // Letter keys (lowercase)
407        "KeyA" | "a" => KeyDefinition {
408            code: "KeyA",
409            key: "a",
410            key_code: 65,
411            text: Some("a"),
412            is_keypad: false,
413            location: 0,
414        },
415        "KeyB" | "b" => KeyDefinition {
416            code: "KeyB",
417            key: "b",
418            key_code: 66,
419            text: Some("b"),
420            is_keypad: false,
421            location: 0,
422        },
423        "KeyC" | "c" => KeyDefinition {
424            code: "KeyC",
425            key: "c",
426            key_code: 67,
427            text: Some("c"),
428            is_keypad: false,
429            location: 0,
430        },
431        "KeyD" | "d" => KeyDefinition {
432            code: "KeyD",
433            key: "d",
434            key_code: 68,
435            text: Some("d"),
436            is_keypad: false,
437            location: 0,
438        },
439        "KeyE" | "e" => KeyDefinition {
440            code: "KeyE",
441            key: "e",
442            key_code: 69,
443            text: Some("e"),
444            is_keypad: false,
445            location: 0,
446        },
447        "KeyF" | "f" => KeyDefinition {
448            code: "KeyF",
449            key: "f",
450            key_code: 70,
451            text: Some("f"),
452            is_keypad: false,
453            location: 0,
454        },
455        "KeyG" | "g" => KeyDefinition {
456            code: "KeyG",
457            key: "g",
458            key_code: 71,
459            text: Some("g"),
460            is_keypad: false,
461            location: 0,
462        },
463        "KeyH" | "h" => KeyDefinition {
464            code: "KeyH",
465            key: "h",
466            key_code: 72,
467            text: Some("h"),
468            is_keypad: false,
469            location: 0,
470        },
471        "KeyI" | "i" => KeyDefinition {
472            code: "KeyI",
473            key: "i",
474            key_code: 73,
475            text: Some("i"),
476            is_keypad: false,
477            location: 0,
478        },
479        "KeyJ" | "j" => KeyDefinition {
480            code: "KeyJ",
481            key: "j",
482            key_code: 74,
483            text: Some("j"),
484            is_keypad: false,
485            location: 0,
486        },
487        "KeyK" | "k" => KeyDefinition {
488            code: "KeyK",
489            key: "k",
490            key_code: 75,
491            text: Some("k"),
492            is_keypad: false,
493            location: 0,
494        },
495        "KeyL" | "l" => KeyDefinition {
496            code: "KeyL",
497            key: "l",
498            key_code: 76,
499            text: Some("l"),
500            is_keypad: false,
501            location: 0,
502        },
503        "KeyM" | "m" => KeyDefinition {
504            code: "KeyM",
505            key: "m",
506            key_code: 77,
507            text: Some("m"),
508            is_keypad: false,
509            location: 0,
510        },
511        "KeyN" | "n" => KeyDefinition {
512            code: "KeyN",
513            key: "n",
514            key_code: 78,
515            text: Some("n"),
516            is_keypad: false,
517            location: 0,
518        },
519        "KeyO" | "o" => KeyDefinition {
520            code: "KeyO",
521            key: "o",
522            key_code: 79,
523            text: Some("o"),
524            is_keypad: false,
525            location: 0,
526        },
527        "KeyP" | "p" => KeyDefinition {
528            code: "KeyP",
529            key: "p",
530            key_code: 80,
531            text: Some("p"),
532            is_keypad: false,
533            location: 0,
534        },
535        "KeyQ" | "q" => KeyDefinition {
536            code: "KeyQ",
537            key: "q",
538            key_code: 81,
539            text: Some("q"),
540            is_keypad: false,
541            location: 0,
542        },
543        "KeyR" | "r" => KeyDefinition {
544            code: "KeyR",
545            key: "r",
546            key_code: 82,
547            text: Some("r"),
548            is_keypad: false,
549            location: 0,
550        },
551        "KeyS" | "s" => KeyDefinition {
552            code: "KeyS",
553            key: "s",
554            key_code: 83,
555            text: Some("s"),
556            is_keypad: false,
557            location: 0,
558        },
559        "KeyT" | "t" => KeyDefinition {
560            code: "KeyT",
561            key: "t",
562            key_code: 84,
563            text: Some("t"),
564            is_keypad: false,
565            location: 0,
566        },
567        "KeyU" | "u" => KeyDefinition {
568            code: "KeyU",
569            key: "u",
570            key_code: 85,
571            text: Some("u"),
572            is_keypad: false,
573            location: 0,
574        },
575        "KeyV" | "v" => KeyDefinition {
576            code: "KeyV",
577            key: "v",
578            key_code: 86,
579            text: Some("v"),
580            is_keypad: false,
581            location: 0,
582        },
583        "KeyW" | "w" => KeyDefinition {
584            code: "KeyW",
585            key: "w",
586            key_code: 87,
587            text: Some("w"),
588            is_keypad: false,
589            location: 0,
590        },
591        "KeyX" | "x" => KeyDefinition {
592            code: "KeyX",
593            key: "x",
594            key_code: 88,
595            text: Some("x"),
596            is_keypad: false,
597            location: 0,
598        },
599        "KeyY" | "y" => KeyDefinition {
600            code: "KeyY",
601            key: "y",
602            key_code: 89,
603            text: Some("y"),
604            is_keypad: false,
605            location: 0,
606        },
607        "KeyZ" | "z" => KeyDefinition {
608            code: "KeyZ",
609            key: "z",
610            key_code: 90,
611            text: Some("z"),
612            is_keypad: false,
613            location: 0,
614        },
615
616        // Uppercase letters (need Shift)
617        "A" => KeyDefinition {
618            code: "KeyA",
619            key: "A",
620            key_code: 65,
621            text: Some("A"),
622            is_keypad: false,
623            location: 0,
624        },
625        "B" => KeyDefinition {
626            code: "KeyB",
627            key: "B",
628            key_code: 66,
629            text: Some("B"),
630            is_keypad: false,
631            location: 0,
632        },
633        "C" => KeyDefinition {
634            code: "KeyC",
635            key: "C",
636            key_code: 67,
637            text: Some("C"),
638            is_keypad: false,
639            location: 0,
640        },
641        "D" => KeyDefinition {
642            code: "KeyD",
643            key: "D",
644            key_code: 68,
645            text: Some("D"),
646            is_keypad: false,
647            location: 0,
648        },
649        "E" => KeyDefinition {
650            code: "KeyE",
651            key: "E",
652            key_code: 69,
653            text: Some("E"),
654            is_keypad: false,
655            location: 0,
656        },
657        "F" => KeyDefinition {
658            code: "KeyF",
659            key: "F",
660            key_code: 70,
661            text: Some("F"),
662            is_keypad: false,
663            location: 0,
664        },
665        "G" => KeyDefinition {
666            code: "KeyG",
667            key: "G",
668            key_code: 71,
669            text: Some("G"),
670            is_keypad: false,
671            location: 0,
672        },
673        "H" => KeyDefinition {
674            code: "KeyH",
675            key: "H",
676            key_code: 72,
677            text: Some("H"),
678            is_keypad: false,
679            location: 0,
680        },
681        "I" => KeyDefinition {
682            code: "KeyI",
683            key: "I",
684            key_code: 73,
685            text: Some("I"),
686            is_keypad: false,
687            location: 0,
688        },
689        "J" => KeyDefinition {
690            code: "KeyJ",
691            key: "J",
692            key_code: 74,
693            text: Some("J"),
694            is_keypad: false,
695            location: 0,
696        },
697        "K" => KeyDefinition {
698            code: "KeyK",
699            key: "K",
700            key_code: 75,
701            text: Some("K"),
702            is_keypad: false,
703            location: 0,
704        },
705        "L" => KeyDefinition {
706            code: "KeyL",
707            key: "L",
708            key_code: 76,
709            text: Some("L"),
710            is_keypad: false,
711            location: 0,
712        },
713        "M" => KeyDefinition {
714            code: "KeyM",
715            key: "M",
716            key_code: 77,
717            text: Some("M"),
718            is_keypad: false,
719            location: 0,
720        },
721        "N" => KeyDefinition {
722            code: "KeyN",
723            key: "N",
724            key_code: 78,
725            text: Some("N"),
726            is_keypad: false,
727            location: 0,
728        },
729        "O" => KeyDefinition {
730            code: "KeyO",
731            key: "O",
732            key_code: 79,
733            text: Some("O"),
734            is_keypad: false,
735            location: 0,
736        },
737        "P" => KeyDefinition {
738            code: "KeyP",
739            key: "P",
740            key_code: 80,
741            text: Some("P"),
742            is_keypad: false,
743            location: 0,
744        },
745        "Q" => KeyDefinition {
746            code: "KeyQ",
747            key: "Q",
748            key_code: 81,
749            text: Some("Q"),
750            is_keypad: false,
751            location: 0,
752        },
753        "R" => KeyDefinition {
754            code: "KeyR",
755            key: "R",
756            key_code: 82,
757            text: Some("R"),
758            is_keypad: false,
759            location: 0,
760        },
761        "S" => KeyDefinition {
762            code: "KeyS",
763            key: "S",
764            key_code: 83,
765            text: Some("S"),
766            is_keypad: false,
767            location: 0,
768        },
769        "T" => KeyDefinition {
770            code: "KeyT",
771            key: "T",
772            key_code: 84,
773            text: Some("T"),
774            is_keypad: false,
775            location: 0,
776        },
777        "U" => KeyDefinition {
778            code: "KeyU",
779            key: "U",
780            key_code: 85,
781            text: Some("U"),
782            is_keypad: false,
783            location: 0,
784        },
785        "V" => KeyDefinition {
786            code: "KeyV",
787            key: "V",
788            key_code: 86,
789            text: Some("V"),
790            is_keypad: false,
791            location: 0,
792        },
793        "W" => KeyDefinition {
794            code: "KeyW",
795            key: "W",
796            key_code: 87,
797            text: Some("W"),
798            is_keypad: false,
799            location: 0,
800        },
801        "X" => KeyDefinition {
802            code: "KeyX",
803            key: "X",
804            key_code: 88,
805            text: Some("X"),
806            is_keypad: false,
807            location: 0,
808        },
809        "Y" => KeyDefinition {
810            code: "KeyY",
811            key: "Y",
812            key_code: 89,
813            text: Some("Y"),
814            is_keypad: false,
815            location: 0,
816        },
817        "Z" => KeyDefinition {
818            code: "KeyZ",
819            key: "Z",
820            key_code: 90,
821            text: Some("Z"),
822            is_keypad: false,
823            location: 0,
824        },
825
826        // Numpad keys
827        "Numpad0" => KeyDefinition {
828            code: "Numpad0",
829            key: "0",
830            key_code: 96,
831            text: Some("0"),
832            is_keypad: true,
833            location: 3,
834        },
835        "Numpad1" => KeyDefinition {
836            code: "Numpad1",
837            key: "1",
838            key_code: 97,
839            text: Some("1"),
840            is_keypad: true,
841            location: 3,
842        },
843        "Numpad2" => KeyDefinition {
844            code: "Numpad2",
845            key: "2",
846            key_code: 98,
847            text: Some("2"),
848            is_keypad: true,
849            location: 3,
850        },
851        "Numpad3" => KeyDefinition {
852            code: "Numpad3",
853            key: "3",
854            key_code: 99,
855            text: Some("3"),
856            is_keypad: true,
857            location: 3,
858        },
859        "Numpad4" => KeyDefinition {
860            code: "Numpad4",
861            key: "4",
862            key_code: 100,
863            text: Some("4"),
864            is_keypad: true,
865            location: 3,
866        },
867        "Numpad5" => KeyDefinition {
868            code: "Numpad5",
869            key: "5",
870            key_code: 101,
871            text: Some("5"),
872            is_keypad: true,
873            location: 3,
874        },
875        "Numpad6" => KeyDefinition {
876            code: "Numpad6",
877            key: "6",
878            key_code: 102,
879            text: Some("6"),
880            is_keypad: true,
881            location: 3,
882        },
883        "Numpad7" => KeyDefinition {
884            code: "Numpad7",
885            key: "7",
886            key_code: 103,
887            text: Some("7"),
888            is_keypad: true,
889            location: 3,
890        },
891        "Numpad8" => KeyDefinition {
892            code: "Numpad8",
893            key: "8",
894            key_code: 104,
895            text: Some("8"),
896            is_keypad: true,
897            location: 3,
898        },
899        "Numpad9" => KeyDefinition {
900            code: "Numpad9",
901            key: "9",
902            key_code: 105,
903            text: Some("9"),
904            is_keypad: true,
905            location: 3,
906        },
907        "NumpadAdd" => KeyDefinition {
908            code: "NumpadAdd",
909            key: "+",
910            key_code: 107,
911            text: Some("+"),
912            is_keypad: true,
913            location: 3,
914        },
915        "NumpadDecimal" => KeyDefinition {
916            code: "NumpadDecimal",
917            key: ".",
918            key_code: 110,
919            text: Some("."),
920            is_keypad: true,
921            location: 3,
922        },
923        "NumpadDivide" => KeyDefinition {
924            code: "NumpadDivide",
925            key: "/",
926            key_code: 111,
927            text: Some("/"),
928            is_keypad: true,
929            location: 3,
930        },
931        "NumpadMultiply" => KeyDefinition {
932            code: "NumpadMultiply",
933            key: "*",
934            key_code: 106,
935            text: Some("*"),
936            is_keypad: true,
937            location: 3,
938        },
939        "NumpadSubtract" => KeyDefinition {
940            code: "NumpadSubtract",
941            key: "-",
942            key_code: 109,
943            text: Some("-"),
944            is_keypad: true,
945            location: 3,
946        },
947
948        // Special character keys
949        "Backquote" | "`" => KeyDefinition {
950            code: "Backquote",
951            key: "`",
952            key_code: 192,
953            text: Some("`"),
954            is_keypad: false,
955            location: 0,
956        },
957        "Minus" | "-" => KeyDefinition {
958            code: "Minus",
959            key: "-",
960            key_code: 189,
961            text: Some("-"),
962            is_keypad: false,
963            location: 0,
964        },
965        "Equal" | "=" => KeyDefinition {
966            code: "Equal",
967            key: "=",
968            key_code: 187,
969            text: Some("="),
970            is_keypad: false,
971            location: 0,
972        },
973        "BracketLeft" | "[" => KeyDefinition {
974            code: "BracketLeft",
975            key: "[",
976            key_code: 219,
977            text: Some("["),
978            is_keypad: false,
979            location: 0,
980        },
981        "BracketRight" | "]" => KeyDefinition {
982            code: "BracketRight",
983            key: "]",
984            key_code: 221,
985            text: Some("]"),
986            is_keypad: false,
987            location: 0,
988        },
989        "Backslash" | "\\" => KeyDefinition {
990            code: "Backslash",
991            key: "\\",
992            key_code: 220,
993            text: Some("\\"),
994            is_keypad: false,
995            location: 0,
996        },
997        "Semicolon" | ";" => KeyDefinition {
998            code: "Semicolon",
999            key: ";",
1000            key_code: 186,
1001            text: Some(";"),
1002            is_keypad: false,
1003            location: 0,
1004        },
1005        "Quote" | "'" => KeyDefinition {
1006            code: "Quote",
1007            key: "'",
1008            key_code: 222,
1009            text: Some("'"),
1010            is_keypad: false,
1011            location: 0,
1012        },
1013        "Comma" | "," => KeyDefinition {
1014            code: "Comma",
1015            key: ",",
1016            key_code: 188,
1017            text: Some(","),
1018            is_keypad: false,
1019            location: 0,
1020        },
1021        "Period" | "." => KeyDefinition {
1022            code: "Period",
1023            key: ".",
1024            key_code: 190,
1025            text: Some("."),
1026            is_keypad: false,
1027            location: 0,
1028        },
1029        "Slash" | "/" => KeyDefinition {
1030            code: "Slash",
1031            key: "/",
1032            key_code: 191,
1033            text: Some("/"),
1034            is_keypad: false,
1035            location: 0,
1036        },
1037
1038        // Lock keys
1039        "CapsLock" => KeyDefinition {
1040            code: "CapsLock",
1041            key: "CapsLock",
1042            key_code: 20,
1043            text: None,
1044            is_keypad: false,
1045            location: 0,
1046        },
1047        "NumLock" => KeyDefinition {
1048            code: "NumLock",
1049            key: "NumLock",
1050            key_code: 144,
1051            text: None,
1052            is_keypad: false,
1053            location: 0,
1054        },
1055        "ScrollLock" => KeyDefinition {
1056            code: "ScrollLock",
1057            key: "ScrollLock",
1058            key_code: 145,
1059            text: None,
1060            is_keypad: false,
1061            location: 0,
1062        },
1063
1064        // Other special keys
1065        "Pause" => KeyDefinition {
1066            code: "Pause",
1067            key: "Pause",
1068            key_code: 19,
1069            text: None,
1070            is_keypad: false,
1071            location: 0,
1072        },
1073        "PrintScreen" => KeyDefinition {
1074            code: "PrintScreen",
1075            key: "PrintScreen",
1076            key_code: 44,
1077            text: None,
1078            is_keypad: false,
1079            location: 0,
1080        },
1081        "ContextMenu" => KeyDefinition {
1082            code: "ContextMenu",
1083            key: "ContextMenu",
1084            key_code: 93,
1085            text: None,
1086            is_keypad: false,
1087            location: 0,
1088        },
1089
1090        _ => return None,
1091    })
1092}