Skip to content

Commit a2adbdf

Browse files
committed
Add flow annotation to getEventKey.
1 parent 646781b commit a2adbdf

File tree

1 file changed

+39
-37
lines changed

1 file changed

+39
-37
lines changed

packages/react-dom/src/events/getEventKey.js

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
68
*/
79

810
import getEventCharCode from './getEventCharCode';
@@ -32,49 +34,49 @@ var normalizeKey = {
3234
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
3335
*/
3436
var translateToKey = {
35-
8: 'Backspace',
36-
9: 'Tab',
37-
12: 'Clear',
38-
13: 'Enter',
39-
16: 'Shift',
40-
17: 'Control',
41-
18: 'Alt',
42-
19: 'Pause',
43-
20: 'CapsLock',
44-
27: 'Escape',
45-
32: ' ',
46-
33: 'PageUp',
47-
34: 'PageDown',
48-
35: 'End',
49-
36: 'Home',
50-
37: 'ArrowLeft',
51-
38: 'ArrowUp',
52-
39: 'ArrowRight',
53-
40: 'ArrowDown',
54-
45: 'Insert',
55-
46: 'Delete',
56-
112: 'F1',
57-
113: 'F2',
58-
114: 'F3',
59-
115: 'F4',
60-
116: 'F5',
61-
117: 'F6',
62-
118: 'F7',
63-
119: 'F8',
64-
120: 'F9',
65-
121: 'F10',
66-
122: 'F11',
67-
123: 'F12',
68-
144: 'NumLock',
69-
145: 'ScrollLock',
70-
224: 'Meta',
37+
'8': 'Backspace',
38+
'9': 'Tab',
39+
'12': 'Clear',
40+
'13': 'Enter',
41+
'16': 'Shift',
42+
'17': 'Control',
43+
'18': 'Alt',
44+
'19': 'Pause',
45+
'20': 'CapsLock',
46+
'27': 'Escape',
47+
'32': ' ',
48+
'33': 'PageUp',
49+
'34': 'PageDown',
50+
'35': 'End',
51+
'36': 'Home',
52+
'37': 'ArrowLeft',
53+
'38': 'ArrowUp',
54+
'39': 'ArrowRight',
55+
'40': 'ArrowDown',
56+
'45': 'Insert',
57+
'46': 'Delete',
58+
'112': 'F1',
59+
'113': 'F2',
60+
'114': 'F3',
61+
'115': 'F4',
62+
'116': 'F5',
63+
'117': 'F6',
64+
'118': 'F7',
65+
'119': 'F8',
66+
'120': 'F9',
67+
'121': 'F10',
68+
'122': 'F11',
69+
'123': 'F12',
70+
'144': 'NumLock',
71+
'145': 'ScrollLock',
72+
'224': 'Meta',
7173
};
7274

7375
/**
7476
* @param {object} nativeEvent Native browser event.
7577
* @return {string} Normalized `key` property.
7678
*/
77-
function getEventKey(nativeEvent) {
79+
function getEventKey(nativeEvent: KeyboardEvent): string {
7880
if (nativeEvent.key) {
7981
// Normalize inconsistent values reported by browsers due to
8082
// implementations of a working draft specification.

0 commit comments

Comments
 (0)