-
Notifications
You must be signed in to change notification settings - Fork 252
/
keyMap.ts
81 lines (71 loc) · 2.15 KB
/
keyMap.ts
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
import {DOM_KEY_LOCATION, keyboardKey} from '../system/keyboard'
/**
* Mapping for a default US-104-QWERTY keyboard
*/
export const defaultKeyMap: keyboardKey[] = [
// alphanumeric keys
...'0123456789'.split('').map(c => ({code: `Digit${c}`, key: c})),
...')!@#$%^&*('
.split('')
.map((c, i) => ({code: `Digit${i}`, key: c, shiftKey: true})),
...'abcdefghijklmnopqrstuvwxyz'
.split('')
.map(c => ({code: `Key${c.toUpperCase()}`, key: c})),
...'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
.split('')
.map(c => ({code: `Key${c}`, key: c, shiftKey: true})),
// alphanumeric block - functional
{code: 'Space', key: ' '},
{code: 'AltLeft', key: 'Alt', location: DOM_KEY_LOCATION.LEFT},
{code: 'AltRight', key: 'Alt', location: DOM_KEY_LOCATION.RIGHT},
{
code: 'ShiftLeft',
key: 'Shift',
location: DOM_KEY_LOCATION.LEFT,
},
{
code: 'ShiftRight',
key: 'Shift',
location: DOM_KEY_LOCATION.RIGHT,
},
{
code: 'ControlLeft',
key: 'Control',
location: DOM_KEY_LOCATION.LEFT,
},
{
code: 'ControlRight',
key: 'Control',
location: DOM_KEY_LOCATION.RIGHT,
},
{code: 'MetaLeft', key: 'Meta', location: DOM_KEY_LOCATION.LEFT},
{
code: 'MetaRight',
key: 'Meta',
location: DOM_KEY_LOCATION.RIGHT,
},
{code: 'OSLeft', key: 'OS', location: DOM_KEY_LOCATION.LEFT},
{code: 'OSRight', key: 'OS', location: DOM_KEY_LOCATION.RIGHT},
{code: 'Tab', key: 'Tab'},
{code: 'CapsLock', key: 'CapsLock'},
{code: 'Backspace', key: 'Backspace'},
{code: 'Enter', key: 'Enter'},
// function
{code: 'Escape', key: 'Escape'},
// arrows
{code: 'ArrowUp', key: 'ArrowUp'},
{code: 'ArrowDown', key: 'ArrowDown'},
{code: 'ArrowLeft', key: 'ArrowLeft'},
{code: 'ArrowRight', key: 'ArrowRight'},
// control pad
{code: 'Home', key: 'Home'},
{code: 'End', key: 'End'},
{code: 'Delete', key: 'Delete'},
{code: 'PageUp', key: 'PageUp'},
{code: 'PageDown', key: 'PageDown'},
// Special keys that are not part of a default US-layout but included for specific behavior
{code: 'Fn', key: 'Fn'},
{code: 'Symbol', key: 'Symbol'},
{code: 'AltRight', key: 'AltGraph'},
// TODO: add mappings
]