Last active
December 30, 2015 21:19
-
-
Save joeylin/7886324 to your computer and use it in GitHub Desktop.
common process to key event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// key name | |
var key_names = { | |
32: 'SPACE', | |
13: 'ENTER', | |
9: 'TAB', | |
8: 'BACKSPACE', | |
16: 'SHIFT', | |
17: 'CTRL', | |
18: 'ALT', | |
20: 'CAPS_LOCK', | |
144: 'NUM_LOCK', | |
145: 'SCROLL_LOCK', | |
37: 'LEFT', | |
38: 'UP', | |
39: 'RIGHT', | |
40: 'DOWN', | |
33: 'PAGE_UP', | |
34: 'PAGE_DOWN', | |
36: 'HOME', | |
35: 'END', | |
45: 'INSERT', | |
46: 'DELETE', | |
27: 'ESCAPE', | |
19: 'PAUSE', | |
222: "'" | |
}; | |
// get key | |
var key = e.keyCode || e.which; | |
// detect right click | |
var rightclick = (e.which) ? (e.which == 3) : (e.button == 2); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment