-
Notifications
You must be signed in to change notification settings - Fork 1
/
key.js
27 lines (27 loc) · 1.18 KB
/
key.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
_.split.guard['['] = ']';
_.parsers.push([/\[([^ ]+)\]/, function(event, handler, key) {//'
var dash;
while ((dash = key.indexOf('-')) > 0) {
event[key.substring(0, dash)+'Key'] = true;
key = key.substring(dash+1);
}
if (key) {
event.keyCode = _.codes[key] || parseInt(key, 10) || key;
}
}]);
_.codes = {
backspace:8, tab:9, enter:13, shift:16, ctrl:17, alt:18, capsLock:20, escape:27, start:91, command:224,
pageUp:33, pageDown:34, end:35, home:36, left:37, up:38, right:39, down:40, insert:45, 'delete':46,
multiply:106, plus:107, minus:109, point:110, divide:111, numLock:144,// numpad controls
';':186, '=':187, ',':188, '-':189, '.':190, '/':191, '`':192, '[':219, '\\':220, ']':221, '\'':222, space:32// symbols
};
for (var n=0; n<10; n++){ _.codes['num'+n] = 96+n; }// numpad numbers
for (var f=1; f<13; f++){ _.codes['f'+f] = 111+f; }// function keys
'abcdefghijklmnopqrstuvwxyz 0123456789'.split('').forEach(function(c) {
_.codes[c] = c.toUpperCase().charCodeAt(0);// ascii keyboard
});
Eventi.on(_, 'on:handler', function(e, handler) {
if (handler.event.keyCode && !handler.event.type) {
handler.event.type = 'keyup';
}
});