-
Notifications
You must be signed in to change notification settings - Fork 1
/
charcodes.coffee
126 lines (122 loc) · 2.32 KB
/
charcodes.coffee
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
###
# This file is part of Xpra.
# Copyright (C) 2010-2013 Antoine Martin <[email protected]>
# Licensed under MPL 2.0, see:
# http://www.mozilla.org/MPL/2.0/
#
###
###*
# Maps web keycodes to the X11 keysym so we can generate a matching X11 keymap.
#
# TODO: some values are missing..
###
###*
# Converts an event into a list of modifiers.
#
# @param event
# @returns {Array} of strings
###
get_event_modifiers = (event) ->
modifiers = []
if event.modifiers
if event.modifiers & Event.ALT_MASK
modifiers.push 'alt'
if event.modifiers & Event.CONTROL_MASK
modifiers.push 'control'
if event.modifiers & Event.SHIFT_MASK
modifiers.push 'shift'
if event.modifiers & Event.META_MASK
modifiers.push 'meta'
else
if event.altKey
modifiers.push 'alt'
if event.ctrlKey
modifiers.push 'control'
if event.metaKey
modifiers.push 'meta'
if event.shiftKey
modifiers.push 'shift'
modifiers
CHARCODE_TO_NAME =
8: 'BackSpace'
9: 'Tab'
12: 'KP_Begin'
13: 'Return'
16: 'Shift_L'
17: 'Control_L'
18: 'Alt_L'
19: 'Pause'
20: 'Caps_Lock'
27: 'Escape'
31: 'Mode_switch'
32: 'space'
33: 'Prior'
34: 'Next'
35: 'End'
36: 'Home'
37: 'Left'
38: 'Up'
39: 'Right'
40: 'Down'
42: 'Print'
45: 'Insert'
46: 'Delete'
58: 'colon'
59: 'semicolon'
60: 'less'
61: 'equal'
62: 'greater'
63: 'question'
64: 'at'
91: 'Menu'
92: 'Menu'
93: 'KP_Enter'
106: 'KP_Multiply'
107: 'KP_Add'
109: 'KP_Subtract'
110: 'KP_Delete'
111: 'KP_Divide'
144: 'Num_Lock'
145: 'Scroll_Lock'
160: 'dead_circumflex'
167: 'underscore'
161: 'exclam'
162: 'quotedbl'
163: 'numbersign'
164: 'dollar'
165: 'percent'
166: 'ampersand'
167: 'underscore'
168: 'parenleft'
169: 'parenright'
170: 'asterisk'
171: 'plus'
172: 'pipe'
173: 'minus'
174: 'braceleft'
175: 'braceright'
176: 'asciitilde'
186: 'semicolon'
187: 'equal'
188: 'comma'
189: 'minus'
190: 'period'
191: 'slash'
192: 'grave'
219: 'bracketright'
220: 'backslash'
221: 'bracketleft'
222: 'apostrophe'
i = 0
while i < 26
CHARCODE_TO_NAME[65 + i] = 'abcdefghijklmnopqrstuvwxyz'[i]
i++
i = 0
while i < 10
CHARCODE_TO_NAME[48 + i] = '' + i
CHARCODE_TO_NAME[96 + i] = 'KP_' + i
i++
i = 1
while i <= 24
CHARCODE_TO_NAME[111 + i] = 'F' + i
i++