From be0e09e01b4975f7ebc24642b72271596555f4be Mon Sep 17 00:00:00 2001 From: overflowerror Date: Sat, 24 May 2014 00:57:19 +0200 Subject: [PATCH] some cool changes for the key-hit-system --- Emulator.js | 4 ++-- KeyCodes.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Emulator.js b/Emulator.js index c49d007..c733711 100644 --- a/Emulator.js +++ b/Emulator.js @@ -84,7 +84,7 @@ Emulator.handleKeyPress = function(e) { } Emulator.handleKeyDown = function(e) { var keycode = Emulator.getKeyCode(e); - if (keycode == 8 || keycode == 46) { + if (KeyCodes.isSpecialKey(keycode)) { Emulator.handleKeyPress(e); return false; } @@ -177,7 +177,7 @@ Emulator.ANSISequences.output = function(text) { Emulator.Output.cursorOff(); Emulator.Output.moveCursor(0, - parseInt(specialText), false); Emulator.Output.cursorOn(); - normalText = ""; + normalText = ""; specialText = ""; specialText2 = ""; state = 0; diff --git a/KeyCodes.js b/KeyCodes.js index 51f71be..1746c8f 100644 --- a/KeyCodes.js +++ b/KeyCodes.js @@ -3,6 +3,17 @@ var KeyCodes = function() { KeyCodes.normalKey = function(code) { return String.fromCharCode(code); } +KeyCodes.isSpecialKey = function(code) { + return (code == 8) || + (code == 10) || + (code == 13) || + (code == 27) || + (code == 37) || + (code == 38) || + (code == 39) || + (code == 40) || + (code == 46); +} KeyCodes.isBackspace = function(code) { return (code == 8); }