-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathkey.go
More file actions
860 lines (828 loc) · 18.3 KB
/
key.go
File metadata and controls
860 lines (828 loc) · 18.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
package vaxis
import (
"bytes"
"fmt"
"strings"
"unicode"
"unicode/utf8"
"git.sr.ht/~rockorager/vaxis/ansi"
)
// Key is a key event. Codepoint can be either the literal codepoint of the
// keypress, or a value set by Vaxis to indicate special keys. Special keys have
// their codepoints outside of the valid unicode range
type Key struct {
// Text is text that the keypress generated
Text string
// Keycode is our primary key press. In alternate layouts, this will be
// the lowercase value of the unicode point
Keycode rune
// The shifted keycode of this key event. This will only be non-zero if
// the shift-modifier was used to generate the event
ShiftedCode rune
// BaseLayoutCode is the keycode that would have been generated on a
// standard PC-101 layout
BaseLayoutCode rune
// Modifiers are any key modifier used to generate the event
Modifiers ModifierMask
// EventType is the type of key event this was (press, release, repeat,
// or paste)
EventType EventType
}
// Matches returns true if there is any way for the passed key and mods to match
// the [Key]. Before matching, ModCapsLock and ModNumLock are removed from the
// modifier mask. Returns true if any of the following are true
//
// 1. Keycode and Modifiers are exact matches
// 2. Text and Modifiers are exact matches
// 3. ShiftedCode and Modifiers (with ModShift removed) are exact matches
// 4. BaseLayoutCode and Modifiers are exact matches
//
// If key is not a letter, but still a graphic: (so we can match ':', which is
// shift+; but we don't want to match "shift+tab" as the same as "tab")
//
// 5. Keycode and Modifers (without ModShift) are exact matches
// 6. Shifted Keycode and Modifers (without ModShift) are exact matches
//
// If key is lowercase or not a letter and mods includes ModShift, uppercase
// Key, remove ModShift and continue
//
// 6. Text and Modifiers are exact matches
func (k Key) Matches(key rune, modifiers ...ModifierMask) bool {
var mods ModifierMask
for _, mod := range modifiers {
mods |= mod
}
mods = mods &^ ModCapsLock
mods = mods &^ ModNumLock
kMods := k.Modifiers &^ ModCapsLock
kMods = kMods &^ ModNumLock
unshiftedkMods := kMods &^ ModShift
unshiftedMods := mods &^ ModShift
// Rule 1
if k.Keycode == key && mods == kMods {
return true
}
// Rule 2
if k.Text == string(key) && mods == kMods {
return true
}
// Rule 3
if k.ShiftedCode == key && mods == unshiftedkMods {
return true
}
// Rule 4
if k.BaseLayoutCode == key && mods == kMods {
return true
}
// Rule 5
if !unicode.IsLetter(key) && unicode.IsGraphic(key) {
if k.Keycode == key && unshiftedkMods == unshiftedMods {
return true
}
if k.ShiftedCode == key && unshiftedkMods == unshiftedMods {
return true
}
}
// Rule 6
if mods&ModShift != 0 && unicode.IsLower(key) {
key = unicode.ToUpper(key)
if k.Text == string(key) && unshiftedMods == unshiftedkMods {
return true
}
}
return false
}
// MatchString parses a string and matches to the Key event. The syntax for
// strings is: <modifier>[+<modifer>]+<key>. For example:
//
// Ctrl+p
// Shift+Alt+Up
//
// All modifiers will be matched lowercase
func (k Key) MatchString(tgt string) bool {
if tgt == "" {
return false
}
if r, n := utf8.DecodeRuneInString(tgt); n == len(tgt) {
// fast path if the 'tgt' is a single utf8 codepoint
return k.Matches(r)
}
vals := strings.Split(tgt, "+")
mods := vals[0 : len(vals)-1]
key := vals[len(vals)-1]
var mask ModifierMask
for _, m := range mods {
switch strings.ToLower(m) {
case "shift":
mask |= ModShift
case "alt":
mask |= ModAlt
case "ctrl":
mask |= ModCtrl
case "super":
mask |= ModSuper
case "meta":
mask |= ModMeta
case "caps":
mask |= ModCapsLock
case "num":
mask |= ModNumLock
}
}
if r, n := utf8.DecodeRuneInString(key); n == len(key) {
// fast path if the 'key' is unicode
return k.Matches(r, mask)
}
for _, kn := range keyNames {
if !strings.EqualFold(kn.name, key) {
continue
}
return k.Matches(kn.key, mask)
}
// maybe it's a multi-byte, non special character. Grab the first rune
// and try matching
for _, r := range key {
return k.Matches(r, mask)
}
// not a match
return false
}
// ModifierMask is a bitmask for which modifier keys were held when a key was
// pressed
type ModifierMask int
const (
// Values equivalent to kitty keyboard protocol
ModShift ModifierMask = 1 << iota
ModAlt
ModCtrl
ModSuper
ModHyper
ModMeta
ModCapsLock
ModNumLock
)
// EventType is an input event type (press, repeat, release, etc)
type EventType int
const (
// The key / button was pressed
EventPress EventType = iota
// The key / button was repeated
EventRepeat
// The key / button was released
EventRelease
// A mouse motion event (with or without a button press)
EventMotion
// The key resulted from a paste
EventPaste
)
// String returns a human-readable description of the keypress, suitable for use
// in matching ("Ctrl+c")
func (k Key) String() string {
buf := &bytes.Buffer{}
if k.EventType != EventRelease {
// if k.Modifiers&ModNumLock != 0 {
// buf.WriteString("num-")
// }
// if k.Modifiers&ModCapsLock != 0 {
// buf.WriteString("caps-")
// }
if k.Modifiers&ModMeta != 0 {
buf.WriteString("Meta+")
}
if k.Modifiers&ModHyper != 0 {
buf.WriteString("Hyper+")
}
if k.Modifiers&ModSuper != 0 {
buf.WriteString("Super+")
}
if k.Modifiers&ModCtrl != 0 {
buf.WriteString("Ctrl+")
}
if k.Modifiers&ModAlt != 0 {
buf.WriteString("Alt+")
}
if k.Modifiers&ModShift != 0 {
buf.WriteString("Shift+")
}
}
switch {
case k.Keycode == KeyTab:
case k.Keycode == KeySpace:
case k.Keycode == KeyEsc:
case k.Keycode == KeyBackspace:
case k.Keycode == KeyEnter:
case k.Keycode == 0x08:
k.Keycode = KeyBackspace
case k.Keycode < 0x00:
return "invalid"
case k.Keycode < 0x20:
var val rune
switch {
case k.Keycode == 0x00:
val = '@'
case k.Keycode <= 0x1A:
// normalize these to lowercase runes
val = k.Keycode + 0x60
case k.Keycode < 0x20:
val = k.Keycode + 0x40
}
return fmt.Sprintf("Ctrl+%c", val)
case k.Keycode <= unicode.MaxRune:
if k.Modifiers&ModCapsLock != 0 {
buf.WriteRune(unicode.ToUpper(k.Keycode))
} else {
buf.WriteRune(k.Keycode)
}
}
for _, kn := range keyNames {
if kn.key != k.Keycode {
continue
}
buf.WriteString(kn.name)
break
}
return buf.String()
}
func decodeKey(seq ansi.Sequence) Key {
key := Key{}
switch seq := seq.(type) {
case ansi.Print:
// For decoding keys, we take the first rune
var raw rune
for _, r := range seq.Grapheme {
raw = r
break
}
key.Keycode = raw
if unicode.IsUpper(raw) {
key.Keycode = unicode.ToLower(raw)
key.ShiftedCode = raw
// It's a shifted character
key.Modifiers = ModShift
}
if key.Keycode != KeyBackspace {
key.Text = seq.Grapheme
}
// NOTE: we don't set baselayout code on printed keys. In legacy
// encodings, this is meaningless. In kitty, this is best used to map
// keybinds and we should only get ansi.Print types when a paste occurs
case ansi.C0:
switch rune(seq) {
case 0x08:
key.Keycode = KeyBackspace
case 0x09:
key.Keycode = KeyTab
case 0x0D:
key.Keycode = KeyEnter
case 0x1B:
key.Keycode = KeyEsc
default:
key.Modifiers = ModCtrl
switch {
case rune(seq) == 0x00:
key.Keycode = '@'
case rune(seq) <= 0x1A:
// normalize these to lowercase runes
key.Keycode = rune(seq) + 0x60
case rune(seq) < 0x20:
key.Keycode = rune(seq) + 0x40
}
}
case ansi.ESC:
key.Keycode = seq.Final
key.Modifiers = ModAlt
case ansi.SS3:
switch rune(seq) {
case 'A':
key.Keycode = KeyUp
case 'B':
key.Keycode = KeyDown
case 'C':
key.Keycode = KeyRight
case 'D':
key.Keycode = KeyLeft
case 'F':
key.Keycode = KeyEnd
case 'H':
key.Keycode = KeyHome
case 'P':
key.Keycode = KeyF01
case 'Q':
key.Keycode = KeyF02
case 'R':
key.Keycode = KeyF03
case 'S':
key.Keycode = KeyF04
}
case ansi.CSI:
if len(seq.Parameters) == 0 {
seq.Parameters = [][]int{
{1},
}
}
for i, pm := range seq.Parameters {
switch i {
case 0:
for j, ps := range pm {
switch j {
case 0:
// our keycode
// unicode-key-code
// This will always be length of at least 1
sk := specialKey{rune(ps), seq.Final}
if sk.keycode == 1 && sk.final == 'Z' {
key.Keycode = KeyTab
key.Modifiers = ModShift
continue
}
var ok bool
key.Keycode, ok = specialsKeys[sk]
if !ok {
key.Keycode = rune(ps)
}
case 1:
// Shifted keycode
key.ShiftedCode = rune(ps)
case 2:
// Base layout code
key.BaseLayoutCode = rune(ps)
}
}
case 1:
// Kitty keyboard protocol reports these as their
// bitmask + 1, so that an unmodified key has a value of
// 1. We subtract one to normalize to our internal
// representation
for j, ps := range pm {
switch j {
case 0:
// Modifiers
key.Modifiers = ModifierMask(pm[0] - 1)
if key.Modifiers < 0 {
key.Modifiers = 0
}
case 1:
// event type
//
key.EventType = EventType(ps) - 1
}
}
case 2:
// text-as-codepoint
if key.Keycode == 27 && seq.Final == '~' && len(pm) > 0 {
// Special case: Ctrl+Enter, Ctrl+Tab, ... are sent as 27;mods;key~
key.Keycode = rune(pm[0])
} else {
for _, p := range pm {
key.Text += string(rune(p))
}
}
}
}
}
// Remove caps and num, if all we have left is shift and no text was
// generated, check if our codepoint is printable and we'll force some
// text. This check is to get around a bug in ghostty and foot where
// shift+space generates \x1b[32;2u with the disambiguate flag on. This
// can be removed in the future when these are fixed (I've submitted
// patches to both terminals)
nmods := key.Modifiers &^ (ModCapsLock | ModNumLock)
if key.Text == "" && nmods == ModShift && unicode.IsPrint(key.Keycode) {
key.Text = string(unicode.ToUpper(key.Keycode))
}
return key
}
type specialKey struct {
keycode rune
final rune
}
const (
extended = unicode.MaxRune + 1
)
const (
KeyUp rune = extended + 1 + iota
KeyRight
KeyDown
KeyLeft
KeyInsert
KeyDelete
KeyPgDown
KeyPgUp
KeyHome
KeyEnd
KeyF00
KeyF01
KeyF02
KeyF03
KeyF04
KeyF05
KeyF06
KeyF07
KeyF08
KeyF09
KeyF10
KeyF11
KeyF12
KeyF13
KeyF14
KeyF15
KeyF16
KeyF17
KeyF18
KeyF19
KeyF20
KeyF21
KeyF22
KeyF23
KeyF24
KeyF25
KeyF26
KeyF27
KeyF28
KeyF29
KeyF30
KeyF31
KeyF32
KeyF33
KeyF34
KeyF35
KeyF36
KeyF37
KeyF38
KeyF39
KeyF40
KeyF41
KeyF42
KeyF43
KeyF44
KeyF45
KeyF46
KeyF47
KeyF48
KeyF49
KeyF50
KeyF51
KeyF52
KeyF53
KeyF54
KeyF55
KeyF56
KeyF57
KeyF58
KeyF59
KeyF60
KeyF61
KeyF62
KeyF63 // F63 is max defined in terminfo
KeyClear
KeyDownLeft
KeyDownRight
KeyUpLeft
KeyUpRight
KeyCenter
KeyBegin
KeyCancel
KeyClose
KeyCommand
KeyCopy
KeyExit
KeyPrint
KeyRefresh
// notcurses says these are only avaialbe in kitty kbp
KeyCapsLock
KeyScrollLock
KeyNumlock
KeyPrintScreen
KeyPause
KeyMenu
// Media keys, also generally only kitty kbp
KeyMediaPlay
KeyMediaPause
KeyMediaPlayPause
KeyMediaRev
KeyMediaStop
KeyMediaFF
KeyMediaRewind
KeyMediaNext
KeyMediaPrev
KeyMediaRecord
KeyMediaVolDown
KeyMediaVolUp
KeyMediaMute
// Modifiers, when pressed by themselves
KeyLeftShift
KeyLeftControl
KeyLeftAlt
KeyLeftSuper
KeyLeftHyper
KeyLeftMeta
KeyRightShift
KeyRightControl
KeyRightAlt
KeyRightSuper
KeyRightHyper
KeyRightMeta
KeyL3Shift
KeyL5Shift
// Numerical pad keys, also generally only kitty kbp
KeyKeyPad0
KeyKeyPad1
KeyKeyPad2
KeyKeyPad3
KeyKeyPad4
KeyKeyPad5
KeyKeyPad6
KeyKeyPad7
KeyKeyPad8
KeyKeyPad9
KeyKeyPadDecimal
KeyKeyPadDivide
KeyKeyPadMultiply
KeyKeyPadSubtract
KeyKeyPadAdd
KeyKeyPadEnter
KeyKeyPadEqual
KeyKeyPadSeparator
KeyKeyPadLeft
KeyKeyPadRight
KeyKeyPadUp
KeyKeyPadDown
KeyKeyPadPageUp
KeyKeyPadPageDown
KeyKeyPadHome
KeyKeyPadEnd
KeyKeyPadInsert
KeyKeyPadDelete
KeyKeyPadBegin
// Aliases
KeyEnter = 0x0D
KeyReturn = KeyEnter
KeyTab = 0x09
KeyEsc = 0x1B
KeySpace = 0x20
KeyBackspace = 0x7F
)
var specialsKeys = map[specialKey]rune{
{27, 'u'}: KeyEsc,
{13, 'u'}: KeyEnter,
{9, 'u'}: KeyTab,
{127, 'u'}: KeyBackspace,
{2, '~'}: KeyInsert,
{3, '~'}: KeyDelete,
{1, 'D'}: KeyLeft,
{1, 'C'}: KeyRight,
{1, 'B'}: KeyDown,
{1, 'A'}: KeyUp,
{5, '~'}: KeyPgUp,
{6, '~'}: KeyPgDown,
{1, 'F'}: KeyEnd,
{4, '~'}: KeyEnd,
{8, '~'}: KeyEnd,
{1, 'H'}: KeyHome,
{1, '~'}: KeyHome,
{7, '~'}: KeyHome,
{57358, 'u'}: KeyCapsLock,
{57359, 'u'}: KeyScrollLock,
{57360, 'u'}: KeyNumlock,
{57361, 'u'}: KeyPrintScreen,
{57362, 'u'}: KeyPause,
{57363, 'u'}: KeyMenu,
{1, 'P'}: KeyF01,
{11, '~'}: KeyF01,
{1, 'Q'}: KeyF02,
{12, '~'}: KeyF02,
{1, 'R'}: KeyF03,
{13, '~'}: KeyF03,
{1, 'S'}: KeyF04,
{14, '~'}: KeyF04,
{15, '~'}: KeyF05,
{17, '~'}: KeyF06,
{18, '~'}: KeyF07,
{19, '~'}: KeyF08,
{20, '~'}: KeyF09,
{21, '~'}: KeyF10,
{23, '~'}: KeyF11,
{24, '~'}: KeyF12,
// DEC vt220 F13-F20 definitions
{25, '~'}: KeyF13,
{26, '~'}: KeyF14,
{28, '~'}: KeyF15,
{29, '~'}: KeyF16,
{31, '~'}: KeyF17,
{32, '~'}: KeyF18,
{33, '~'}: KeyF19,
{34, '~'}: KeyF20,
// Kitty encodings F13+
{57376, 'u'}: KeyF13,
{57377, 'u'}: KeyF14,
{57378, 'u'}: KeyF15,
{57379, 'u'}: KeyF16,
{57380, 'u'}: KeyF17,
{57381, 'u'}: KeyF18,
{57382, 'u'}: KeyF19,
{57383, 'u'}: KeyF20,
{57384, 'u'}: KeyF21,
{57385, 'u'}: KeyF22,
{57386, 'u'}: KeyF23,
{57387, 'u'}: KeyF24,
{57388, 'u'}: KeyF25,
{57389, 'u'}: KeyF26,
{57390, 'u'}: KeyF27,
{57391, 'u'}: KeyF28,
{57392, 'u'}: KeyF29,
{57393, 'u'}: KeyF30,
{57394, 'u'}: KeyF31,
{57395, 'u'}: KeyF32,
{57396, 'u'}: KeyF33,
{57397, 'u'}: KeyF34,
{57398, 'u'}: KeyF35,
{57399, 'u'}: KeyKeyPad0,
{57400, 'u'}: KeyKeyPad1,
{57401, 'u'}: KeyKeyPad2,
{57402, 'u'}: KeyKeyPad3,
{57403, 'u'}: KeyKeyPad4,
{57404, 'u'}: KeyKeyPad5,
{57405, 'u'}: KeyKeyPad6,
{57406, 'u'}: KeyKeyPad7,
{57407, 'u'}: KeyKeyPad8,
{57408, 'u'}: KeyKeyPad9,
{57409, 'u'}: KeyKeyPadDecimal,
{57410, 'u'}: KeyKeyPadDivide,
{57411, 'u'}: KeyKeyPadMultiply,
{57412, 'u'}: KeyKeyPadSubtract,
{57413, 'u'}: KeyKeyPadAdd,
{57414, 'u'}: KeyKeyPadEnter,
{57415, 'u'}: KeyKeyPadEqual,
{57416, 'u'}: KeyKeyPadSeparator,
{57417, 'u'}: KeyKeyPadLeft,
{57418, 'u'}: KeyKeyPadRight,
{57419, 'u'}: KeyKeyPadUp,
{57420, 'u'}: KeyKeyPadDown,
{57421, 'u'}: KeyKeyPadPageUp,
{57422, 'u'}: KeyKeyPadPageDown,
{57423, 'u'}: KeyKeyPadHome,
{57424, 'u'}: KeyKeyPadEnd,
{57425, 'u'}: KeyKeyPadInsert,
{57426, 'u'}: KeyKeyPadDelete,
{1, 'E'}: KeyKeyPadBegin,
{57427, '~'}: KeyKeyPadBegin,
{57428, 'u'}: KeyMediaPlay,
{57429, 'u'}: KeyMediaPause,
{57430, 'u'}: KeyMediaPlayPause,
{57431, 'u'}: KeyMediaRev,
{57432, 'u'}: KeyMediaStop,
{57433, 'u'}: KeyMediaFF,
{57434, 'u'}: KeyMediaRewind,
{57435, 'u'}: KeyMediaNext,
{57436, 'u'}: KeyMediaPrev,
{57437, 'u'}: KeyMediaRecord,
{57438, 'u'}: KeyMediaVolDown,
{57439, 'u'}: KeyMediaVolUp,
{57440, 'u'}: KeyMediaMute,
{57441, 'u'}: KeyLeftShift,
{57442, 'u'}: KeyLeftControl,
{57443, 'u'}: KeyLeftAlt,
{57444, 'u'}: KeyLeftSuper,
{57445, 'u'}: KeyLeftHyper,
{57446, 'u'}: KeyLeftMeta,
{57447, 'u'}: KeyRightShift,
{57448, 'u'}: KeyRightControl,
{57449, 'u'}: KeyRightAlt,
{57450, 'u'}: KeyRightSuper,
{57451, 'u'}: KeyRightHyper,
{57452, 'u'}: KeyRightMeta,
{57453, 'u'}: KeyL3Shift,
{57454, 'u'}: KeyL5Shift,
}
type keyName struct {
key rune
name string
}
var keyNames = []keyName{
{KeyUp, "Up"},
{KeyRight, "Right"},
{KeyDown, "Down"},
{KeyLeft, "Left"},
{KeyInsert, "Insert"},
{KeyDelete, "Delete"},
{KeyBackspace, "BackSpace"},
{KeyPgDown, "Page_Down"},
{KeyPgUp, "Page_Up"},
{KeyHome, "Home"},
{KeyEnd, "End"},
{KeyF00, "F0"},
{KeyF01, "F1"},
{KeyF02, "F2"},
{KeyF03, "F3"},
{KeyF04, "F4"},
{KeyF05, "F5"},
{KeyF06, "F6"},
{KeyF07, "F7"},
{KeyF08, "F8"},
{KeyF09, "F9"},
{KeyF10, "F10"},
{KeyF11, "F11"},
{KeyF12, "F12"},
{KeyF13, "F13"},
{KeyF14, "F14"},
{KeyF15, "F15"},
{KeyF16, "F16"},
{KeyF17, "F17"},
{KeyF18, "F18"},
{KeyF19, "F19"},
{KeyF20, "F20"},
{KeyF21, "F21"},
{KeyF22, "F22"},
{KeyF23, "F23"},
{KeyF24, "F24"},
{KeyF25, "F25"},
{KeyF26, "F26"},
{KeyF27, "F27"},
{KeyF28, "F28"},
{KeyF29, "F29"},
{KeyF30, "F30"},
{KeyF31, "F31"},
{KeyF32, "F32"},
{KeyF33, "F33"},
{KeyF34, "F34"},
{KeyF35, "F35"},
{KeyF36, "F36"},
{KeyF37, "F37"},
{KeyF38, "F38"},
{KeyF39, "F39"},
{KeyF40, "F40"},
{KeyF41, "F41"},
{KeyF42, "F42"},
{KeyF43, "F43"},
{KeyF44, "F44"},
{KeyF45, "F45"},
{KeyF46, "F46"},
{KeyF47, "F47"},
{KeyF48, "F48"},
{KeyF49, "F49"},
{KeyF50, "F50"},
{KeyF51, "F51"},
{KeyF52, "F52"},
{KeyF53, "F53"},
{KeyF54, "F54"},
{KeyF55, "F55"},
{KeyF56, "F56"},
{KeyF57, "F57"},
{KeyF58, "F58"},
{KeyF59, "F59"},
{KeyF60, "F60"},
{KeyF61, "F61"},
{KeyF62, "F62"},
{KeyF63, "F63"},
{KeyEnter, "Enter"},
{KeyClear, "Clear"},
{KeyDownLeft, "DownLeft"},
{KeyDownRight, "DownRight"},
{KeyUpLeft, "UpLeft"},
{KeyUpRight, "UpRight"},
{KeyCenter, "Center"},
{KeyBegin, "Begin"},
{KeyCancel, "Cancel"},
{KeyClose, "Close"},
{KeyCommand, "Cmd"},
{KeyCopy, "Copy"},
{KeyExit, "Exit"},
{KeyPrint, "Print"},
{KeyRefresh, "Refresh"},
{KeyCapsLock, "Caps_Lock"},
{KeyScrollLock, "Scroll_Lock"},
{KeyNumlock, "Num_Lock"},
{KeyPrintScreen, "Print"},
{KeyPause, "Pause"},
{KeyMenu, "Menu"},
{KeyMediaPlay, "Media_Play"},
{KeyMediaPause, "Media_Pause"},
{KeyMediaPlayPause, "Media_Play_Pause"},
{KeyMediaRev, "Media_Reverse"},
{KeyMediaStop, "Media_Stop"},
{KeyMediaFF, "Media_Fast_Forward"},
{KeyMediaRewind, "Media_Rewind"},
{KeyMediaNext, "Media_Track_Next"},
{KeyMediaPrev, "Media_Track_Previous"},
{KeyMediaRecord, "Media_Record"},
{KeyMediaVolDown, "Lower_Volume"},
{KeyMediaVolUp, "Raise_Volume"},
{KeyMediaMute, "Mute_Volume"},
{KeyLeftShift, "Shift_L"},
{KeyLeftControl, "Control_L"},
{KeyLeftAlt, "Alt_L"},
{KeyLeftSuper, "Super_L"},
{KeyLeftHyper, "Hyper_L"},
{KeyLeftMeta, "Meta_L"},
{KeyRightShift, "Shift_R"},
{KeyRightControl, "Control_R"},
{KeyRightAlt, "Alt_R"},
{KeyRightSuper, "Super_R"},
{KeyRightHyper, "Hyper_R"},
{KeyRightMeta, "Meta_R"},
{KeyL3Shift, "ISO_Level3_Shift"},
{KeyL5Shift, "ISO_Level5_Shift"},
{KeyTab, "Tab"},
{KeyEsc, "Escape"},
{KeySpace, "space"},
}