// Kind of like a singleton
const Keyboard  = {
    "KEY_UP": 38,
    "KEY_DOWN": 40,
    "KEY_LEFT": 37,
    "KEY_RIGHT": 39,
    "KEY_W": 87,
    "KEY_A": 65,
    "KEY_D": 68,
    "KEY_SPACE": 32,
    "keys": [],
    "keydown_handler": function(evt) {
        Keyboard.keys[evt.keyCode] = true; 
        if (evt.keyCode == Keyboard.KEY_UP ||
            evt.keyCode == Keyboard.KEY_DOWN ||
            evt.keyCode == Keyboard.KEY_LEFT ||
            evt.keyCode == Keyboard.KEY_RIGHT
        )
            evt.preventDefault();
    },
    "keyup_handler": function(evt) {
        //TODO: Remove from array to minimise memory consumption.
        Keyboard.keys[evt.keyCode] = false;
        if (evt.keyCode == Keyboard.KEY_UP ||
            evt.keyCode == Keyboard.KEY_DOWN ||
            evt.keyCode == Keyboard.KEY_LEFT ||
            evt.keyCode == Keyboard.KEY_RIGHT
        )
            evt.preventDefault();
    },
    "pressed": function(keyCode) {
        return Keyboard.keys[keyCode] === true;
    }
}

@@ -41,16 +41,35 @@
 rd  = %7B%0A
+    %22KEY_ESC%22: 27,%0A
     %22KEY
@@ -78,16 +78,16 @@
 P%22: 38,%0A
-
     %22KEY
@@ -227,16 +227,36 @@
 s%22: %5B%5D,%0A
+    %22nKeysDown%22: 0,%0A
     %22key
@@ -278,32 +278,63 @@
 function(evt) %7B%0A
+        Keyboard.nKeysDown ++;%0A
         Keyboard
@@ -703,16 +703,43 @@
 mption.%0A
+        this.nKeysDown --;%0A
         
@@ -1044,24 +1044,24 @@
 (keyCode) %7B%0A
-
         retu
@@ -1096,16 +1096,93 @@
 = true;%0A
+    %7D,%0A    %22anyKeyDown%22: function() %7B%0A        return Keyboard.nKeysDown %3E 0;%0A
     %7D%0A%7D%0A

Add any key test and ESC constant