# HG changeset patch # User John "Elwin" Edwards # Date 1336421304 25200 # Node ID 21738794755eb542b0ec4c1fa8061944347cf9f5 # Parent e880f7589db55c319a5d82d23d74c92a169d2e92 Put common key tables into a common file. diff -r e880f7589db5 -r 21738794755e index-rlg.html --- a/index-rlg.html Mon May 07 12:50:02 2012 -0700 +++ b/index-rlg.html Mon May 07 13:08:24 2012 -0700 @@ -3,6 +3,7 @@ WebTTY + diff -r e880f7589db5 -r 21738794755e index-sh.html --- a/index-sh.html Mon May 07 12:50:02 2012 -0700 +++ b/index-sh.html Mon May 07 13:08:24 2012 -0700 @@ -3,6 +3,7 @@ WebTTY + diff -r e880f7589db5 -r 21738794755e rlgterm.js --- a/rlgterm.js Mon May 07 12:50:02 2012 -0700 +++ b/rlgterm.js Mon May 07 13:08:24 2012 -0700 @@ -181,69 +181,6 @@ return; } -/* ASCII values of keys 0-9. */ -var numShifts = [41, 33, 64, 35, 36, 37, 94, 38, 42, 40]; - -var keyHexCodes = { - init: function () { - this[KeyboardEvent.DOM_VK_RETURN] = ["0d", "0d"]; - this[KeyboardEvent.DOM_VK_SPACE] = ["20", "20"]; - this[KeyboardEvent.DOM_VK_TAB] = ["09", "09"]; - this[KeyboardEvent.DOM_VK_BACK_QUOTE] = ["60", "7e"]; - this[KeyboardEvent.DOM_VK_OPEN_BRACKET] = ["5b", "7b"]; - this[KeyboardEvent.DOM_VK_CLOSE_BRACKET] = ["5d", "7d"]; - this[KeyboardEvent.DOM_VK_BACK_SLASH] = ["5c", "7c"]; - this[KeyboardEvent.DOM_VK_SEMICOLON] = ["3b", "3a"]; - this[KeyboardEvent.DOM_VK_QUOTE] = ["27", "22"]; - this[KeyboardEvent.DOM_VK_COMMA] = ["2c", "3c"]; - this[KeyboardEvent.DOM_VK_PERIOD] = ["2e", "3e"]; - this[KeyboardEvent.DOM_VK_SLASH] = ["2f", "3f"]; - this[KeyboardEvent.DOM_VK_EQUALS] = ["3d", "2b"]; - this[KeyboardEvent.DOM_VK_SUBTRACT] = ["2d", "5f"]; - this[KeyboardEvent.DOM_VK_BACK_SPACE] = ["08", "08"]; - this[KeyboardEvent.DOM_VK_ESCAPE] = ["1b", "1b"]; - /* Multi-char control sequences! Neat! */ - this[KeyboardEvent.DOM_VK_PAGE_UP] = ["1b5b357e", "1b5b357e"]; - this[KeyboardEvent.DOM_VK_PAGE_DOWN] = ["1b5b367e", "1b5b367e"]; - this.appCursor(false); - this.appKeypad(false); - }, - appCursor: function (on) { - if (on) { - this[KeyboardEvent.DOM_VK_LEFT] = ["1b4f44", "1b4f44"]; - this[KeyboardEvent.DOM_VK_RIGHT] = ["1b4f43", "1b4f43"]; - this[KeyboardEvent.DOM_VK_UP] = ["1b4f41", "1b4f41"]; - this[KeyboardEvent.DOM_VK_DOWN] = ["1b4f42", "1b4f42"]; - this[KeyboardEvent.DOM_VK_END] = ["1b4f46", "1b4f46"]; - this[KeyboardEvent.DOM_VK_HOME] = ["1b4f48", "1b4f48"]; - } - else { - this[KeyboardEvent.DOM_VK_LEFT] = ["1b5b44", "1b5b44"]; - this[KeyboardEvent.DOM_VK_RIGHT] = ["1b5b43", "1b5b43"]; - this[KeyboardEvent.DOM_VK_UP] = ["1b5b41", "1b5b41"]; - this[KeyboardEvent.DOM_VK_DOWN] = ["1b5b42", "1b5b42"]; - this[KeyboardEvent.DOM_VK_END] = ["1b5b46", "1b5b46"]; - this[KeyboardEvent.DOM_VK_HOME] = ["1b5b48", "1b5b48"]; - } - }, - appKeypad: function (on) { - /* In theory, these should produce either numerals or the k[a-c][1-3] - * sequences. Since we can't count on the terminfo description actually - * containing those sequences, pretend they're just arrow keys etc. - */ - this[KeyboardEvent.DOM_VK_NUMPAD1] = ["1b4f46", "1b4f46"]; - this[KeyboardEvent.DOM_VK_NUMPAD2] = ["1b4f42", "1b4f42"]; - this[KeyboardEvent.DOM_VK_NUMPAD3] = ["1b5b367e", "1b5b367e"]; - this[KeyboardEvent.DOM_VK_NUMPAD4] = ["1b4f44", "1b4f44"]; - this[KeyboardEvent.DOM_VK_NUMPAD5] = ["1b5b45", "1b5b45"]; - this[KeyboardEvent.DOM_VK_NUMPAD6] = ["1b4f43", "1b4f43"]; - this[KeyboardEvent.DOM_VK_NUMPAD7] = ["1b4f48", "1b4f48"]; - this[KeyboardEvent.DOM_VK_NUMPAD8] = ["1b4f41", "1b4f41"]; - this[KeyboardEvent.DOM_VK_NUMPAD9] = ["1b5b357e", "1b5b357e"]; - return; - } -}; - function sendkey(ev) { if (termemu.sessid == null) return; diff -r e880f7589db5 -r 21738794755e shterm.js --- a/shterm.js Mon May 07 12:50:02 2012 -0700 +++ b/shterm.js Mon May 07 13:08:24 2012 -0700 @@ -174,71 +174,6 @@ return; } -/* ASCII values of keys 0-9. */ -var numShifts = [41, 33, 64, 35, 36, 37, 94, 38, 42, 40]; - -var keyHexCodes = { - init: function () { - this[KeyboardEvent.DOM_VK_RETURN] = ["0d", "0d"]; - this[KeyboardEvent.DOM_VK_SPACE] = ["20", "20"]; - this[KeyboardEvent.DOM_VK_TAB] = ["09", "09"]; - this[KeyboardEvent.DOM_VK_BACK_QUOTE] = ["60", "7e"]; - this[KeyboardEvent.DOM_VK_OPEN_BRACKET] = ["5b", "7b"]; - this[KeyboardEvent.DOM_VK_CLOSE_BRACKET] = ["5d", "7d"]; - this[KeyboardEvent.DOM_VK_BACK_SLASH] = ["5c", "7c"]; - this[KeyboardEvent.DOM_VK_SEMICOLON] = ["3b", "3a"]; - this[KeyboardEvent.DOM_VK_QUOTE] = ["27", "22"]; - this[KeyboardEvent.DOM_VK_COMMA] = ["2c", "3c"]; - this[KeyboardEvent.DOM_VK_PERIOD] = ["2e", "3e"]; - this[KeyboardEvent.DOM_VK_SLASH] = ["2f", "3f"]; - this[KeyboardEvent.DOM_VK_EQUALS] = ["3d", "2b"]; - this[KeyboardEvent.DOM_VK_SUBTRACT] = ["2d", "5f"]; - this[KeyboardEvent.DOM_VK_BACK_SPACE] = ["08", "08"]; - this[KeyboardEvent.DOM_VK_DELETE] = ["1b5b337e", "1b5b337e"]; - this[KeyboardEvent.DOM_VK_ESCAPE] = ["1b", "1b"]; - this[KeyboardEvent.DOM_VK_PAGE_UP] = ["1b5b357e", "1b5b357e"]; - this[KeyboardEvent.DOM_VK_PAGE_DOWN] = ["1b5b367e", "1b5b367e"]; - this.appCursor(false); - this.appKeypad(false); - }, - /* Multi-char control sequences! Neat! */ - appCursor: function (on) { - /* Aren't special keys vile? */ - if (on) { - this[KeyboardEvent.DOM_VK_LEFT] = ["1b4f44", "1b4f44"]; - this[KeyboardEvent.DOM_VK_RIGHT] = ["1b4f43", "1b4f43"]; - this[KeyboardEvent.DOM_VK_UP] = ["1b4f41", "1b4f41"]; - this[KeyboardEvent.DOM_VK_DOWN] = ["1b4f42", "1b4f42"]; - this[KeyboardEvent.DOM_VK_END] = ["1b4f46", "1b4f46"]; - this[KeyboardEvent.DOM_VK_HOME] = ["1b4f48", "1b4f48"]; - } - else { - this[KeyboardEvent.DOM_VK_LEFT] = ["1b5b44", "1b5b44"]; - this[KeyboardEvent.DOM_VK_RIGHT] = ["1b5b43", "1b5b43"]; - this[KeyboardEvent.DOM_VK_UP] = ["1b5b41", "1b5b41"]; - this[KeyboardEvent.DOM_VK_DOWN] = ["1b5b42", "1b5b42"]; - this[KeyboardEvent.DOM_VK_END] = ["1b5b46", "1b5b46"]; - this[KeyboardEvent.DOM_VK_HOME] = ["1b5b48", "1b5b48"]; - } - }, - appKeypad: function (on) { - /* In theory, these should produce either numerals or the k[a-c][1-3] - * sequences. Since we can't count on the terminfo description actually - * containing those sequences, pretend they're just arrow keys etc. - */ - this[KeyboardEvent.DOM_VK_NUMPAD1] = ["1b4f46", "1b4f46"]; - this[KeyboardEvent.DOM_VK_NUMPAD2] = ["1b4f42", "1b4f42"]; - this[KeyboardEvent.DOM_VK_NUMPAD3] = ["1b5b367e", "1b5b367e"]; - this[KeyboardEvent.DOM_VK_NUMPAD4] = ["1b4f44", "1b4f44"]; - this[KeyboardEvent.DOM_VK_NUMPAD5] = ["1b5b45", "1b5b45"]; - this[KeyboardEvent.DOM_VK_NUMPAD6] = ["1b4f43", "1b4f43"]; - this[KeyboardEvent.DOM_VK_NUMPAD7] = ["1b4f48", "1b4f48"]; - this[KeyboardEvent.DOM_VK_NUMPAD8] = ["1b4f41", "1b4f41"]; - this[KeyboardEvent.DOM_VK_NUMPAD9] = ["1b5b357e", "1b5b357e"]; - return; - } -}; - function sendkey(ev) { var keynum = ev.keyCode; var code; diff -r e880f7589db5 -r 21738794755e termemu-keys.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/termemu-keys.js Mon May 07 13:08:24 2012 -0700 @@ -0,0 +1,67 @@ +/* termemu-keys.js: some key-handling code common to both drivers. */ + +/* ASCII values of keys 0-9. */ +var numShifts = [41, 33, 64, 35, 36, 37, 94, 38, 42, 40]; + +var keyHexCodes = { + init: function () { + this[KeyboardEvent.DOM_VK_RETURN] = ["0d", "0d"]; + this[KeyboardEvent.DOM_VK_SPACE] = ["20", "20"]; + this[KeyboardEvent.DOM_VK_TAB] = ["09", "09"]; + this[KeyboardEvent.DOM_VK_BACK_QUOTE] = ["60", "7e"]; + this[KeyboardEvent.DOM_VK_OPEN_BRACKET] = ["5b", "7b"]; + this[KeyboardEvent.DOM_VK_CLOSE_BRACKET] = ["5d", "7d"]; + this[KeyboardEvent.DOM_VK_BACK_SLASH] = ["5c", "7c"]; + this[KeyboardEvent.DOM_VK_SEMICOLON] = ["3b", "3a"]; + this[KeyboardEvent.DOM_VK_QUOTE] = ["27", "22"]; + this[KeyboardEvent.DOM_VK_COMMA] = ["2c", "3c"]; + this[KeyboardEvent.DOM_VK_PERIOD] = ["2e", "3e"]; + this[KeyboardEvent.DOM_VK_SLASH] = ["2f", "3f"]; + this[KeyboardEvent.DOM_VK_EQUALS] = ["3d", "2b"]; + this[KeyboardEvent.DOM_VK_SUBTRACT] = ["2d", "5f"]; + this[KeyboardEvent.DOM_VK_BACK_SPACE] = ["08", "08"]; + this[KeyboardEvent.DOM_VK_DELETE] = ["1b5b337e", "1b5b337e"]; + this[KeyboardEvent.DOM_VK_ESCAPE] = ["1b", "1b"]; + this[KeyboardEvent.DOM_VK_PAGE_UP] = ["1b5b357e", "1b5b357e"]; + this[KeyboardEvent.DOM_VK_PAGE_DOWN] = ["1b5b367e", "1b5b367e"]; + this.appCursor(false); + this.appKeypad(false); + }, + /* Multi-char control sequences! Neat! */ + appCursor: function (on) { + /* Aren't special keys vile? */ + if (on) { + this[KeyboardEvent.DOM_VK_LEFT] = ["1b4f44", "1b4f44"]; + this[KeyboardEvent.DOM_VK_RIGHT] = ["1b4f43", "1b4f43"]; + this[KeyboardEvent.DOM_VK_UP] = ["1b4f41", "1b4f41"]; + this[KeyboardEvent.DOM_VK_DOWN] = ["1b4f42", "1b4f42"]; + this[KeyboardEvent.DOM_VK_END] = ["1b4f46", "1b4f46"]; + this[KeyboardEvent.DOM_VK_HOME] = ["1b4f48", "1b4f48"]; + } + else { + this[KeyboardEvent.DOM_VK_LEFT] = ["1b5b44", "1b5b44"]; + this[KeyboardEvent.DOM_VK_RIGHT] = ["1b5b43", "1b5b43"]; + this[KeyboardEvent.DOM_VK_UP] = ["1b5b41", "1b5b41"]; + this[KeyboardEvent.DOM_VK_DOWN] = ["1b5b42", "1b5b42"]; + this[KeyboardEvent.DOM_VK_END] = ["1b5b46", "1b5b46"]; + this[KeyboardEvent.DOM_VK_HOME] = ["1b5b48", "1b5b48"]; + } + }, + appKeypad: function (on) { + /* In theory, these should produce either numerals or the k[a-c][1-3] + * sequences. Since we can't count on the terminfo description actually + * containing those sequences, pretend they're just arrow keys etc. + */ + this[KeyboardEvent.DOM_VK_NUMPAD1] = ["1b4f46", "1b4f46"]; + this[KeyboardEvent.DOM_VK_NUMPAD2] = ["1b4f42", "1b4f42"]; + this[KeyboardEvent.DOM_VK_NUMPAD3] = ["1b5b367e", "1b5b367e"]; + this[KeyboardEvent.DOM_VK_NUMPAD4] = ["1b4f44", "1b4f44"]; + this[KeyboardEvent.DOM_VK_NUMPAD5] = ["1b5b45", "1b5b45"]; + this[KeyboardEvent.DOM_VK_NUMPAD6] = ["1b4f43", "1b4f43"]; + this[KeyboardEvent.DOM_VK_NUMPAD7] = ["1b4f48", "1b4f48"]; + this[KeyboardEvent.DOM_VK_NUMPAD8] = ["1b4f41", "1b4f41"]; + this[KeyboardEvent.DOM_VK_NUMPAD9] = ["1b5b357e", "1b5b357e"]; + return; + } +}; +