diff rlgterm.js @ 76:a497ecd116d9

Improvements to the keyboard. Add a number pad to the keyboard. Make it hidden by default for RLG-Web.
author John "Elwin" Edwards <elwin@sdf.org>
date Sat, 23 Jun 2012 17:11:51 -0700
parents 2984604ce3e6
children f8bb37f48d58
line wrap: on
line diff
--- a/rlgterm.js	Thu Jun 21 23:44:51 2012 -0700
+++ b/rlgterm.js	Sat Jun 23 17:11:51 2012 -0700
@@ -327,6 +327,10 @@
   ';': "3a", '\'': "22", ',': "3c", '.': "3e", '/': "3f", '`': "7e"
 }
 
+var kpkeys = { "KP1": "1b4f46", "KP2": "1b4f42", "KP3": "1b5b367e", 
+               "KP4": "1b4f44", "KP5": "1b5b45", "KP6": "1b4f43", 
+               "KP7": "1b4f48", "KP8": "1b4f41", "KP9": "1b5b357e" };
+
 function vkey(c) {
   if (!session.playing)
     return;
@@ -363,6 +367,9 @@
     else
       keystr = c.charCodeAt(0).toString(16);
   }
+  else if (c in kpkeys) {
+    keystr = kpkeys[c];
+  }
   else
     return;
   var datareq = new XMLHttpRequest();
@@ -760,11 +767,14 @@
   }
 }
 
-function toggledebug() {
-  if (document.getElementById("debug").style.display != "block")
-    document.getElementById("debug").style.display = "block";
+function toggleBlock(id) {
+  var element = document.getElementById(id);
+  if (!element)
+    return;
+  if (element.style.display != "block")
+    element.style.display = "block";
   else
-    document.getElementById("debug").style.display = "none";
+    element.style.display = "none";
 }
 
 function debug(level, msg) {