Prevent default browser action for SPACEBAR and ARROW keys
[shapeshift.git] / shapeshift.js
index ed05a37577947edb0c4405782e0e28c27e2f9077..e59f65c5a3d474c696bd65a379682a7e2089a131 100644 (file)
             [ { actor: 'guard',  text: "(By the way, this is the end of the game.\nYou really can't do anything more.\nThanks for playing!)" } ];
 
 
+        window.addEventListener("keydown", function(e) {
+            // Prevent default browser action for arrows and spacebar
+            if([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) {
+            e.preventDefault();
+            }
+        }, false);
+
         function sign(n) {
             if (n >= 0) { return 1 } else { return -1 };
         }
 
         }
 
-        function putText(entity, text, color = '#000000') {
-            var textObject = game.add.text(entity.x, entity.y - (entity.height / 2) - 30, text, { align: 'center', fill: color, fontSize: 14 });
+        function putText(entity, text) {
+            var textObject = game.add.text(entity.x, entity.y - (entity.height / 2) - 30, text, { align: 'center', fontSize: 14 });
             textObject.font = 'Ubuntu Mono';
             textObject.anchor.setTo(.5,.5);
             return textObject;