Mercurial > hg > rlgwebd
comparison termemu-keys.js @ 6:21738794755e
Put common key tables into a common file.
author | John "Elwin" Edwards <elwin@sdf.org> |
---|---|
date | Mon, 07 May 2012 13:08:24 -0700 |
parents | |
children | d7eb63cd7a16 |
comparison
equal
deleted
inserted
replaced
5:e880f7589db5 | 6:21738794755e |
---|---|
1 /* termemu-keys.js: some key-handling code common to both drivers. */ | |
2 | |
3 /* ASCII values of keys 0-9. */ | |
4 var numShifts = [41, 33, 64, 35, 36, 37, 94, 38, 42, 40]; | |
5 | |
6 var keyHexCodes = { | |
7 init: function () { | |
8 this[KeyboardEvent.DOM_VK_RETURN] = ["0d", "0d"]; | |
9 this[KeyboardEvent.DOM_VK_SPACE] = ["20", "20"]; | |
10 this[KeyboardEvent.DOM_VK_TAB] = ["09", "09"]; | |
11 this[KeyboardEvent.DOM_VK_BACK_QUOTE] = ["60", "7e"]; | |
12 this[KeyboardEvent.DOM_VK_OPEN_BRACKET] = ["5b", "7b"]; | |
13 this[KeyboardEvent.DOM_VK_CLOSE_BRACKET] = ["5d", "7d"]; | |
14 this[KeyboardEvent.DOM_VK_BACK_SLASH] = ["5c", "7c"]; | |
15 this[KeyboardEvent.DOM_VK_SEMICOLON] = ["3b", "3a"]; | |
16 this[KeyboardEvent.DOM_VK_QUOTE] = ["27", "22"]; | |
17 this[KeyboardEvent.DOM_VK_COMMA] = ["2c", "3c"]; | |
18 this[KeyboardEvent.DOM_VK_PERIOD] = ["2e", "3e"]; | |
19 this[KeyboardEvent.DOM_VK_SLASH] = ["2f", "3f"]; | |
20 this[KeyboardEvent.DOM_VK_EQUALS] = ["3d", "2b"]; | |
21 this[KeyboardEvent.DOM_VK_SUBTRACT] = ["2d", "5f"]; | |
22 this[KeyboardEvent.DOM_VK_BACK_SPACE] = ["08", "08"]; | |
23 this[KeyboardEvent.DOM_VK_DELETE] = ["1b5b337e", "1b5b337e"]; | |
24 this[KeyboardEvent.DOM_VK_ESCAPE] = ["1b", "1b"]; | |
25 this[KeyboardEvent.DOM_VK_PAGE_UP] = ["1b5b357e", "1b5b357e"]; | |
26 this[KeyboardEvent.DOM_VK_PAGE_DOWN] = ["1b5b367e", "1b5b367e"]; | |
27 this.appCursor(false); | |
28 this.appKeypad(false); | |
29 }, | |
30 /* Multi-char control sequences! Neat! */ | |
31 appCursor: function (on) { | |
32 /* Aren't special keys vile? */ | |
33 if (on) { | |
34 this[KeyboardEvent.DOM_VK_LEFT] = ["1b4f44", "1b4f44"]; | |
35 this[KeyboardEvent.DOM_VK_RIGHT] = ["1b4f43", "1b4f43"]; | |
36 this[KeyboardEvent.DOM_VK_UP] = ["1b4f41", "1b4f41"]; | |
37 this[KeyboardEvent.DOM_VK_DOWN] = ["1b4f42", "1b4f42"]; | |
38 this[KeyboardEvent.DOM_VK_END] = ["1b4f46", "1b4f46"]; | |
39 this[KeyboardEvent.DOM_VK_HOME] = ["1b4f48", "1b4f48"]; | |
40 } | |
41 else { | |
42 this[KeyboardEvent.DOM_VK_LEFT] = ["1b5b44", "1b5b44"]; | |
43 this[KeyboardEvent.DOM_VK_RIGHT] = ["1b5b43", "1b5b43"]; | |
44 this[KeyboardEvent.DOM_VK_UP] = ["1b5b41", "1b5b41"]; | |
45 this[KeyboardEvent.DOM_VK_DOWN] = ["1b5b42", "1b5b42"]; | |
46 this[KeyboardEvent.DOM_VK_END] = ["1b5b46", "1b5b46"]; | |
47 this[KeyboardEvent.DOM_VK_HOME] = ["1b5b48", "1b5b48"]; | |
48 } | |
49 }, | |
50 appKeypad: function (on) { | |
51 /* In theory, these should produce either numerals or the k[a-c][1-3] | |
52 * sequences. Since we can't count on the terminfo description actually | |
53 * containing those sequences, pretend they're just arrow keys etc. | |
54 */ | |
55 this[KeyboardEvent.DOM_VK_NUMPAD1] = ["1b4f46", "1b4f46"]; | |
56 this[KeyboardEvent.DOM_VK_NUMPAD2] = ["1b4f42", "1b4f42"]; | |
57 this[KeyboardEvent.DOM_VK_NUMPAD3] = ["1b5b367e", "1b5b367e"]; | |
58 this[KeyboardEvent.DOM_VK_NUMPAD4] = ["1b4f44", "1b4f44"]; | |
59 this[KeyboardEvent.DOM_VK_NUMPAD5] = ["1b5b45", "1b5b45"]; | |
60 this[KeyboardEvent.DOM_VK_NUMPAD6] = ["1b4f43", "1b4f43"]; | |
61 this[KeyboardEvent.DOM_VK_NUMPAD7] = ["1b4f48", "1b4f48"]; | |
62 this[KeyboardEvent.DOM_VK_NUMPAD8] = ["1b4f41", "1b4f41"]; | |
63 this[KeyboardEvent.DOM_VK_NUMPAD9] = ["1b5b357e", "1b5b357e"]; | |
64 return; | |
65 } | |
66 }; | |
67 |