-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
158 lines (153 loc) · 6.38 KB
/
index.js
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
const keys = new Map();
keys.set(1, { name: 'ESC', char: '' });
keys.set(2, { name: '1', char: '1' });
keys.set(3, { name: '2', char: '2' });
keys.set(4, { name: '3', char: '3' });
keys.set(5, { name: '4', char: '4' });
keys.set(6, { name: '5', char: '5' });
keys.set(7, { name: '6', char: '6' });
keys.set(8, { name: '7', char: '7' });
keys.set(9, { name: '8', char: '8' });
keys.set(10, { name: '9', char: '9' });
keys.set(11, { name: '0', char: '0' });
keys.set(12, { name: 'MINUS', char: '-' });
keys.set(13, { name: 'EQUAL', char: '=' });
keys.set(14, { name: 'BACKSPACE', char: '' });
keys.set(15, { name: 'TAB', char: '\t' });
keys.set(16, { name: 'Q', char: 'Q' });
keys.set(17, { name: 'W', char: 'W' });
keys.set(18, { name: 'E', char: 'E' });
keys.set(19, { name: 'R', char: 'R' });
keys.set(20, { name: 'T', char: 'T' });
keys.set(21, { name: 'Y', char: 'Y' });
keys.set(22, { name: 'U', char: 'U' });
keys.set(23, { name: 'I', char: 'I' });
keys.set(24, { name: 'O', char: 'O' });
keys.set(25, { name: 'P', char: 'P' });
keys.set(26, { name: 'LEFT_BRACE', char: '(' });
keys.set(27, { name: 'RIGHT_BRACE', char: ')' });
keys.set(28, { name: 'ENTER', char: '\n' });
keys.set(29, { name: 'LEFT_CTRL', char: '' });
keys.set(30, { name: 'A', char: 'A' });
keys.set(31, { name: 'S', char: 'S' });
keys.set(32, { name: 'D', char: 'D' });
keys.set(33, { name: 'F', char: 'F' });
keys.set(34, { name: 'G', char: 'G' });
keys.set(35, { name: 'H', char: 'H' });
keys.set(36, { name: 'J', char: 'J' });
keys.set(37, { name: 'K', char: 'K' });
keys.set(38, { name: 'L', char: 'L' });
keys.set(39, { name: 'SEMICOLON', char: ';' });
keys.set(40, { name: 'APOSTROPHE', char: '\'' });
keys.set(41, { name: 'GRAVE', char: '`' });
keys.set(42, { name: 'LEFT_SHIFT', char: '' });
keys.set(43, { name: 'BACKSLASH', char: '\\' });
keys.set(44, { name: 'A', char: 'A' });
keys.set(45, { name: 'S', char: 'S' });
keys.set(46, { name: 'D', char: 'D' });
keys.set(47, { name: 'F', char: 'F' });
keys.set(48, { name: 'G', char: 'G' });
keys.set(49, { name: 'H', char: 'H' });
keys.set(50, { name: 'J', char: 'J' });
keys.set(51, { name: 'COMMA', char: ',' });
keys.set(52, { name: 'DOT', char: '.' });
keys.set(53, { name: 'SLASH', char: '/' });
keys.set(54, { name: 'RIGHT_SHIFT', char: '' });
keys.set(55, { name: 'KP_ASTERISK', char: '' });
keys.set(56, { name: 'LEFT_ALT', char: '' });
keys.set(57, { name: 'SPACE', char: ' ' });
keys.set(58, { name: 'CAPS_LOCK', char: '' });
keys.set(59, { name: 'F1', char: '' });
keys.set(60, { name: 'F2', char: '' });
keys.set(61, { name: 'F3', char: '' });
keys.set(62, { name: 'F4', char: '' });
keys.set(63, { name: 'F5', char: '' });
keys.set(64, { name: 'F6', char: '' });
keys.set(65, { name: 'F7', char: '' });
keys.set(66, { name: 'F8', char: '' });
keys.set(67, { name: 'F9', char: '' });
keys.set(68, { name: 'F10', char: '' });
keys.set(69, { name: 'NUM_LOCK', char: '' });
keys.set(70, { name: 'SCROLL_LOCK', char: '' });
keys.set(71, { name: 'KP7', char: '' });
keys.set(72, { name: 'KP8', char: '' });
keys.set(73, { name: 'KP9', char: '' });
keys.set(74, { name: 'KP_MINUS', char: '' });
keys.set(75, { name: 'KP4', char: '' });
keys.set(76, { name: 'KP5', char: '' });
keys.set(77, { name: 'KP6', char: '' });
keys.set(78, { name: 'KP_PLUS', char: '' });
keys.set(79, { name: 'KP1', char: '' });
keys.set(80, { name: 'KP2', char: '' });
keys.set(81, { name: 'KP3', char: '' });
keys.set(82, { name: 'KP0', char: '' });
keys.set(83, { name: 'KP_DOT', char: '' });
keys.set(85, { name: 'ZENKAKUHANKAKU', char: '' });
keys.set(86, { name: '102ND', char: '' });
keys.set(87, { name: 'F11', char: '' });
keys.set(88, { name: 'F12', char: '' });
keys.set(89, { name: 'RO', char: '' });
keys.set(90, { name: 'KATAKANA', char: '' });
keys.set(91, { name: 'HIRAGANA', char: '' });
keys.set(92, { name: 'HENKAN', char: '' });
keys.set(93, { name: 'KATAKANAHIRAGANA', char: '' });
keys.set(94, { name: 'MUHENKAN', char: '' });
keys.set(95, { name: 'KP_JP_COMMA', char: '' });
keys.set(96, { name: 'KP_ENTER', char: '' });
keys.set(97, { name: 'RIGHT_CTRL', char: '' });
keys.set(98, { name: 'KP_SLASH', char: '' });
keys.set(99, { name: 'SYS_RQ', char: '' });
keys.set(100, { name: 'RIGHT_ALT', char: '' });
keys.set(102, { name: 'HOME', char: '' });
keys.set(103, { name: 'UP', char: '' });
keys.set(104, { name: 'PAGE_UP', char: '' });
keys.set(105, { name: 'LEFT', char: '' });
keys.set(106, { name: 'RIGHT', char: '' });
keys.set(107, { name: 'END', char: '' });
keys.set(108, { name: 'DOWN', char: '' });
keys.set(109, { name: 'PAGE_DOWN', char: '' });
keys.set(110, { name: 'INSERT', char: '' });
keys.set(111, { name: 'DELETE', char: '' });
keys.set(113, { name: 'MUTE', char: '' });
keys.set(114, { name: 'VOLUME_DOWN', char: '' });
keys.set(115, { name: 'VOLUME_UP', char: '' });
keys.set(116, { name: 'POWER', char: '' });
keys.set(117, { name: 'KP_EQUAL', char: '' });
keys.set(119, { name: 'PAUSE', char: '' });
keys.set(121, { name: 'KP_COMMA', char: '' });
keys.set(122, { name: 'HANGUEL', char: '' });
keys.set(123, { name: 'HANJA', char: '' });
keys.set(124, { name: 'YEN', char: '' });
keys.set(125, { name: 'LEFT_META', char: '' });
keys.set(126, { name: 'RIGHT_META', char: '' });
keys.set(127, { name: 'COMPOSE', char: '' });
keys.set(128, { name: 'STOP', char: '' });
keys.set(129, { name: 'AGAIN', char: '' });
keys.set(130, { name: 'PROPS', char: '' });
keys.set(131, { name: 'UNDO', char: '' });
keys.set(132, { name: 'FRONT', char: '' });
keys.set(133, { name: 'COPY', char: '' });
keys.set(134, { name: 'OPEN', char: '' });
keys.set(135, { name: 'PASTE', char: '' });
keys.set(136, { name: 'FIND', char: '' });
keys.set(137, { name: 'CUT', char: '' });
keys.set(138, { name: 'HELP', char: '' });
keys.set(183, { name: 'F13', char: '' });
keys.set(184, { name: 'F14', char: '' });
keys.set(185, { name: 'F15', char: '' });
keys.set(186, { name: 'F16', char: '' });
keys.set(187, { name: 'F17', char: '' });
keys.set(188, { name: 'F18', char: '' });
keys.set(189, { name: 'F19', char: '' });
keys.set(190, { name: 'F20', char: '' });
keys.set(191, { name: 'F21', char: '' });
keys.set(192, { name: 'F22', char: '' });
keys.set(193, { name: 'F23', char: '' });
keys.set(194, { name: 'F24', char: '' });
function listAllKnownKeys() {
return Array.from(keys.entries()).map(entry => ({ code: entry[0], ...entry[1] }));
}
function keyCodeInfo(keyCode) {
return keys.get(keyCode) || { name: 'UNKNOWN', char: '' };
}
module.exports = { keyCodeInfo, listAllKnownKeys };