comparison rlgterm.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 ee22eb9ab009
children 826a7ced69f8
comparison
equal deleted inserted replaced
5:e880f7589db5 6:21738794755e
178 datareq.onreadystatechange = postResponseHandler; 178 datareq.onreadystatechange = postResponseHandler;
179 datareq.open('POST', '/feed', true); 179 datareq.open('POST', '/feed', true);
180 datareq.send("id=" + termemu.sessid + "&keys=" + str); 180 datareq.send("id=" + termemu.sessid + "&keys=" + str);
181 return; 181 return;
182 } 182 }
183
184 /* ASCII values of keys 0-9. */
185 var numShifts = [41, 33, 64, 35, 36, 37, 94, 38, 42, 40];
186
187 var keyHexCodes = {
188 init: function () {
189 this[KeyboardEvent.DOM_VK_RETURN] = ["0d", "0d"];
190 this[KeyboardEvent.DOM_VK_SPACE] = ["20", "20"];
191 this[KeyboardEvent.DOM_VK_TAB] = ["09", "09"];
192 this[KeyboardEvent.DOM_VK_BACK_QUOTE] = ["60", "7e"];
193 this[KeyboardEvent.DOM_VK_OPEN_BRACKET] = ["5b", "7b"];
194 this[KeyboardEvent.DOM_VK_CLOSE_BRACKET] = ["5d", "7d"];
195 this[KeyboardEvent.DOM_VK_BACK_SLASH] = ["5c", "7c"];
196 this[KeyboardEvent.DOM_VK_SEMICOLON] = ["3b", "3a"];
197 this[KeyboardEvent.DOM_VK_QUOTE] = ["27", "22"];
198 this[KeyboardEvent.DOM_VK_COMMA] = ["2c", "3c"];
199 this[KeyboardEvent.DOM_VK_PERIOD] = ["2e", "3e"];
200 this[KeyboardEvent.DOM_VK_SLASH] = ["2f", "3f"];
201 this[KeyboardEvent.DOM_VK_EQUALS] = ["3d", "2b"];
202 this[KeyboardEvent.DOM_VK_SUBTRACT] = ["2d", "5f"];
203 this[KeyboardEvent.DOM_VK_BACK_SPACE] = ["08", "08"];
204 this[KeyboardEvent.DOM_VK_ESCAPE] = ["1b", "1b"];
205 /* Multi-char control sequences! Neat! */
206 this[KeyboardEvent.DOM_VK_PAGE_UP] = ["1b5b357e", "1b5b357e"];
207 this[KeyboardEvent.DOM_VK_PAGE_DOWN] = ["1b5b367e", "1b5b367e"];
208 this.appCursor(false);
209 this.appKeypad(false);
210 },
211 appCursor: function (on) {
212 if (on) {
213 this[KeyboardEvent.DOM_VK_LEFT] = ["1b4f44", "1b4f44"];
214 this[KeyboardEvent.DOM_VK_RIGHT] = ["1b4f43", "1b4f43"];
215 this[KeyboardEvent.DOM_VK_UP] = ["1b4f41", "1b4f41"];
216 this[KeyboardEvent.DOM_VK_DOWN] = ["1b4f42", "1b4f42"];
217 this[KeyboardEvent.DOM_VK_END] = ["1b4f46", "1b4f46"];
218 this[KeyboardEvent.DOM_VK_HOME] = ["1b4f48", "1b4f48"];
219 }
220 else {
221 this[KeyboardEvent.DOM_VK_LEFT] = ["1b5b44", "1b5b44"];
222 this[KeyboardEvent.DOM_VK_RIGHT] = ["1b5b43", "1b5b43"];
223 this[KeyboardEvent.DOM_VK_UP] = ["1b5b41", "1b5b41"];
224 this[KeyboardEvent.DOM_VK_DOWN] = ["1b5b42", "1b5b42"];
225 this[KeyboardEvent.DOM_VK_END] = ["1b5b46", "1b5b46"];
226 this[KeyboardEvent.DOM_VK_HOME] = ["1b5b48", "1b5b48"];
227 }
228 },
229 appKeypad: function (on) {
230 /* In theory, these should produce either numerals or the k[a-c][1-3]
231 * sequences. Since we can't count on the terminfo description actually
232 * containing those sequences, pretend they're just arrow keys etc.
233 */
234 this[KeyboardEvent.DOM_VK_NUMPAD1] = ["1b4f46", "1b4f46"];
235 this[KeyboardEvent.DOM_VK_NUMPAD2] = ["1b4f42", "1b4f42"];
236 this[KeyboardEvent.DOM_VK_NUMPAD3] = ["1b5b367e", "1b5b367e"];
237 this[KeyboardEvent.DOM_VK_NUMPAD4] = ["1b4f44", "1b4f44"];
238 this[KeyboardEvent.DOM_VK_NUMPAD5] = ["1b5b45", "1b5b45"];
239 this[KeyboardEvent.DOM_VK_NUMPAD6] = ["1b4f43", "1b4f43"];
240 this[KeyboardEvent.DOM_VK_NUMPAD7] = ["1b4f48", "1b4f48"];
241 this[KeyboardEvent.DOM_VK_NUMPAD8] = ["1b4f41", "1b4f41"];
242 this[KeyboardEvent.DOM_VK_NUMPAD9] = ["1b5b357e", "1b5b357e"];
243 return;
244 }
245 };
246 183
247 function sendkey(ev) { 184 function sendkey(ev) {
248 if (termemu.sessid == null) 185 if (termemu.sessid == null)
249 return; 186 return;
250 var keynum = ev.keyCode; 187 var keynum = ev.keyCode;