Mercurial > hg > rlgwebd
comparison termemu-keys.js @ 70:d7eb63cd7a16
Try to get some compatibility for keys.
I'd thought using the DOM_VK_ names was a good idea. Symbolic names
ought to be more portable than opaque numeric constants. Foolish me,
expecting things to be sane.
Keys now work with FF15 and Chrome 17.
author | John "Elwin" Edwards <elwin@sdf.org> |
---|---|
date | Thu, 21 Jun 2012 09:43:52 -0700 |
parents | 21738794755e |
children | 6cfaf6d202be |
comparison
equal
deleted
inserted
replaced
69:0c16f07135dd | 70:d7eb63cd7a16 |
---|---|
3 /* ASCII values of keys 0-9. */ | 3 /* ASCII values of keys 0-9. */ |
4 var numShifts = [41, 33, 64, 35, 36, 37, 94, 38, 42, 40]; | 4 var numShifts = [41, 33, 64, 35, 36, 37, 94, 38, 42, 40]; |
5 | 5 |
6 var keyHexCodes = { | 6 var keyHexCodes = { |
7 init: function () { | 7 init: function () { |
8 this[KeyboardEvent.DOM_VK_RETURN] = ["0d", "0d"]; | 8 this[13] = ["0d", "0d"]; // return |
9 this[KeyboardEvent.DOM_VK_SPACE] = ["20", "20"]; | 9 this[32] = ["20", "20"]; // space |
10 this[KeyboardEvent.DOM_VK_TAB] = ["09", "09"]; | 10 this[9] = ["09", "09"]; // tab |
11 this[KeyboardEvent.DOM_VK_BACK_QUOTE] = ["60", "7e"]; | 11 this[192] = ["60", "7e"]; // backtick, tilde |
12 this[KeyboardEvent.DOM_VK_OPEN_BRACKET] = ["5b", "7b"]; | 12 this[219] = ["5b", "7b"]; // open bracket, open brace |
13 this[KeyboardEvent.DOM_VK_CLOSE_BRACKET] = ["5d", "7d"]; | 13 this[221] = ["5d", "7d"]; // close bracket, close brace |
14 this[KeyboardEvent.DOM_VK_BACK_SLASH] = ["5c", "7c"]; | 14 this[220] = ["5c", "7c"]; // backslash, pipe |
15 this[KeyboardEvent.DOM_VK_SEMICOLON] = ["3b", "3a"]; | 15 this[59] = ["3b", "3a"]; // semicolon, colon |
16 this[KeyboardEvent.DOM_VK_QUOTE] = ["27", "22"]; | 16 this[186] = ["3b", "3a"]; // semicolon, colon (Chrome) |
17 this[KeyboardEvent.DOM_VK_COMMA] = ["2c", "3c"]; | 17 this[222] = ["27", "22"]; // single quote, double quote |
18 this[KeyboardEvent.DOM_VK_PERIOD] = ["2e", "3e"]; | 18 this[188] = ["2c", "3c"]; // comma, less than |
19 this[KeyboardEvent.DOM_VK_SLASH] = ["2f", "3f"]; | 19 this[190] = ["2e", "3e"]; // period, right angle |
20 this[KeyboardEvent.DOM_VK_EQUALS] = ["3d", "2b"]; | 20 this[191] = ["2f", "3f"]; // slash, question mark |
21 this[KeyboardEvent.DOM_VK_SUBTRACT] = ["2d", "5f"]; | 21 this[61] = ["3d", "2b"]; // equal, plus |
22 this[KeyboardEvent.DOM_VK_BACK_SPACE] = ["08", "08"]; | 22 this[187] = ["3d", "2b"]; // equal, plus (Chrome) |
23 this[KeyboardEvent.DOM_VK_DELETE] = ["1b5b337e", "1b5b337e"]; | 23 this[109] = ["2d", "5f"]; // subtract, underscore (maybe on numpad) |
24 this[KeyboardEvent.DOM_VK_ESCAPE] = ["1b", "1b"]; | 24 this[173] = ["2d", "5f"]; // subtract, underscore (maybe not on numpad) |
25 this[KeyboardEvent.DOM_VK_PAGE_UP] = ["1b5b357e", "1b5b357e"]; | 25 this[189] = ["2d", "5f"]; // subtract, underscore (Chrome) |
26 this[KeyboardEvent.DOM_VK_PAGE_DOWN] = ["1b5b367e", "1b5b367e"]; | 26 this[8] = ["08", "08"]; // backspace |
27 this[46] = ["1b5b337e", "1b5b337e"]; // delete | |
28 this[27] = ["1b", "1b"]; // escape | |
29 this[33] = ["1b5b357e", "1b5b357e"]; // page up | |
30 this[34] = ["1b5b367e", "1b5b367e"]; // page down | |
27 this.appCursor(false); | 31 this.appCursor(false); |
28 this.appKeypad(false); | 32 this.appKeypad(false); |
29 }, | 33 }, |
30 /* Multi-char control sequences! Neat! */ | 34 /* Multi-char control sequences! Neat! */ |
31 appCursor: function (on) { | 35 appCursor: function (on) { |
32 /* Aren't special keys vile? */ | 36 /* Aren't special keys vile? */ |
33 if (on) { | 37 if (on) { |
34 this[KeyboardEvent.DOM_VK_LEFT] = ["1b4f44", "1b4f44"]; | 38 this[37] = ["1b4f44", "1b4f44"]; // left arror |
35 this[KeyboardEvent.DOM_VK_RIGHT] = ["1b4f43", "1b4f43"]; | 39 this[39] = ["1b4f43", "1b4f43"]; // right arrow |
36 this[KeyboardEvent.DOM_VK_UP] = ["1b4f41", "1b4f41"]; | 40 this[38] = ["1b4f41", "1b4f41"]; // up arrow |
37 this[KeyboardEvent.DOM_VK_DOWN] = ["1b4f42", "1b4f42"]; | 41 this[40] = ["1b4f42", "1b4f42"]; // down arrow |
38 this[KeyboardEvent.DOM_VK_END] = ["1b4f46", "1b4f46"]; | 42 this[35] = ["1b4f46", "1b4f46"]; // end |
39 this[KeyboardEvent.DOM_VK_HOME] = ["1b4f48", "1b4f48"]; | 43 this[36] = ["1b4f48", "1b4f48"]; // home |
40 } | 44 } |
41 else { | 45 else { |
42 this[KeyboardEvent.DOM_VK_LEFT] = ["1b5b44", "1b5b44"]; | 46 this[37] = ["1b5b44", "1b5b44"]; // left arror |
43 this[KeyboardEvent.DOM_VK_RIGHT] = ["1b5b43", "1b5b43"]; | 47 this[39] = ["1b5b43", "1b5b43"]; // right arrow |
44 this[KeyboardEvent.DOM_VK_UP] = ["1b5b41", "1b5b41"]; | 48 this[38] = ["1b5b41", "1b5b41"]; // up arrow |
45 this[KeyboardEvent.DOM_VK_DOWN] = ["1b5b42", "1b5b42"]; | 49 this[40] = ["1b5b42", "1b5b42"]; // down arrow |
46 this[KeyboardEvent.DOM_VK_END] = ["1b5b46", "1b5b46"]; | 50 this[35] = ["1b5b46", "1b5b46"]; // end |
47 this[KeyboardEvent.DOM_VK_HOME] = ["1b5b48", "1b5b48"]; | 51 this[36] = ["1b5b48", "1b5b48"]; // home |
48 } | 52 } |
49 }, | 53 }, |
50 appKeypad: function (on) { | 54 appKeypad: function (on) { |
51 /* In theory, these should produce either numerals or the k[a-c][1-3] | 55 /* 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 | 56 * sequences. Since we can't count on the terminfo description actually |
53 * containing those sequences, pretend they're just arrow keys etc. | 57 * containing those sequences, pretend they're just arrow keys etc. |
54 */ | 58 */ |
55 this[KeyboardEvent.DOM_VK_NUMPAD1] = ["1b4f46", "1b4f46"]; | 59 this[97] = ["1b4f46", "1b4f46"]; |
56 this[KeyboardEvent.DOM_VK_NUMPAD2] = ["1b4f42", "1b4f42"]; | 60 this[98] = ["1b4f42", "1b4f42"]; |
57 this[KeyboardEvent.DOM_VK_NUMPAD3] = ["1b5b367e", "1b5b367e"]; | 61 this[99] = ["1b5b367e", "1b5b367e"]; |
58 this[KeyboardEvent.DOM_VK_NUMPAD4] = ["1b4f44", "1b4f44"]; | 62 this[100] = ["1b4f44", "1b4f44"]; |
59 this[KeyboardEvent.DOM_VK_NUMPAD5] = ["1b5b45", "1b5b45"]; | 63 this[101] = ["1b5b45", "1b5b45"]; |
60 this[KeyboardEvent.DOM_VK_NUMPAD6] = ["1b4f43", "1b4f43"]; | 64 this[102] = ["1b4f43", "1b4f43"]; |
61 this[KeyboardEvent.DOM_VK_NUMPAD7] = ["1b4f48", "1b4f48"]; | 65 this[103] = ["1b4f48", "1b4f48"]; |
62 this[KeyboardEvent.DOM_VK_NUMPAD8] = ["1b4f41", "1b4f41"]; | 66 this[104] = ["1b4f41", "1b4f41"]; |
63 this[KeyboardEvent.DOM_VK_NUMPAD9] = ["1b5b357e", "1b5b357e"]; | 67 this[105] = ["1b5b357e", "1b5b357e"]; |
64 return; | 68 return; |
65 } | 69 } |
66 }; | 70 }; |
67 | 71 |