Mercurial > hg > rlgwebd
comparison rlgterm.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 | b6a3b26fe0dc |
children | d084610a89b5 |
comparison
equal
deleted
inserted
replaced
69:0c16f07135dd | 70:d7eb63cd7a16 |
---|---|
267 function sendkey(ev) { | 267 function sendkey(ev) { |
268 if (!session.playing) | 268 if (!session.playing) |
269 return; | 269 return; |
270 var keynum = ev.keyCode; | 270 var keynum = ev.keyCode; |
271 var code; | 271 var code; |
272 if (keynum >= ev.DOM_VK_A && keynum <= ev.DOM_VK_Z) { | 272 if (keynum >= 65 && keynum <= 90) { |
273 /* Letters. This assumes the codes are 65-90. */ | 273 /* Letters. */ |
274 if (ev.ctrlKey) | 274 if (ev.ctrlKey) |
275 keynum -= 64; | 275 keynum -= 64; |
276 else if (!ev.shiftKey) | 276 else if (!ev.shiftKey) |
277 keynum += 32; | 277 keynum += 32; |
278 code = keynum.toString(16); | 278 code = keynum.toString(16); |
279 if (code.length < 2) | 279 if (code.length < 2) |
280 code = "0" + code; | 280 code = "0" + code; |
281 } | 281 } |
282 else if (keynum >= ev.DOM_VK_0 && keynum <= ev.DOM_VK_9) { | 282 else if (keynum >= 48 && keynum <= 57) { |
283 /* The number row, NOT the numpad. */ | 283 /* The number row, NOT the numpad. */ |
284 if (ev.shiftKey) { | 284 if (ev.shiftKey) { |
285 code = numShifts[keynum - 48].toString(16); | 285 code = numShifts[keynum - 48].toString(16); |
286 } | 286 } |
287 else { | 287 else { |
292 if (ev.shiftKey) | 292 if (ev.shiftKey) |
293 code = keyHexCodes[keynum][1]; | 293 code = keyHexCodes[keynum][1]; |
294 else | 294 else |
295 code = keyHexCodes[keynum][0]; | 295 code = keyHexCodes[keynum][0]; |
296 } | 296 } |
297 else if (keynum == ev.DOM_VK_SHIFT || keynum == ev.DOM_VK_CONTROL || | 297 else if (keynum >= 16 && keynum <= 20) { |
298 keynum == ev.DOM_VK_ALT || keynum == ev.DOM_VK_CAPS_LOCK) { | 298 /* Shift, Cntl, Alt, CAPSLOCK */ |
299 return; | 299 return; |
300 } | 300 } |
301 else { | 301 else { |
302 debug(1, "Ignoring keycode " + keynum); | 302 debug(1, "Ignoring keycode " + keynum); |
303 return; | 303 return; |