diff --git a/Emulator.js b/Emulator.js index eb799aa..17ea6de 100644 --- a/Emulator.js +++ b/Emulator.js @@ -58,9 +58,11 @@ Emulator.addEventHandlers = function() { console.log("Emulator: adding unfocus-event"); this.input.onblur = this.refocus; console.log("Emulator: adding key-press-event"); - this.input.onkeypress = this.handleKeyPress; + //this.input.onkeypress = this.handleKeyPress; + window.onkeypress = this.handleKeyPress; console.log("Emulator: adding key-down-event"); - this.input.onkeydown = this.handleKeyDown; + //this.input.onkeydown = this.handleKeyDown; + window.onkeydown = this.handleKeyDown; var timerid = window.setInterval(function() {/*for (var i = 0; i < 10; i++)*/ Emulator.tick(0);}, 1); Emulator.mainTickId = timerid; console.log("Emulator: adding default 1ms (or cheated 0.1 ms) tick with tid=" + timerid); diff --git a/KeyCodes.js b/KeyCodes.js index b87d8a1..17b1523 100644 --- a/KeyCodes.js +++ b/KeyCodes.js @@ -4,17 +4,26 @@ KeyCodes.normalKey = function(code) { return String.fromCharCode(code); } KeyCodes.isBackspace = function(code) { - if (code == 8) - return true; - return false; + return (code == 8); } KeyCodes.isDelete = function(code) { - if (code == 46) - return true; - return false; + return (code == 46); } KeyCodes.isEnter = function(code) { - if (code == 13) - return true; - return false; + return (code == 13); +} +KeyCodes.isEscape = function(code) { + return (code == 27); +} +KeyCodes.isLeft = function(code) { + return (code == 37); +} +KeyCodes.isUp = function(code) { + return (code == 38); +} +KeyCodes.isRight = function(code) { + return (code == 39); +} +KeyCodes.isDown = function(code) { + return (code == 40); }