mirror of
https://github.com/sigmasternchen/Wish
synced 2025-03-15 15:38:54 +00:00
function key events
This commit is contained in:
parent
1d9bac087f
commit
8fb7da7044
2 changed files with 22 additions and 11 deletions
|
@ -58,9 +58,11 @@ Emulator.addEventHandlers = function() {
|
||||||
console.log("Emulator: adding unfocus-event");
|
console.log("Emulator: adding unfocus-event");
|
||||||
this.input.onblur = this.refocus;
|
this.input.onblur = this.refocus;
|
||||||
console.log("Emulator: adding key-press-event");
|
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");
|
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);
|
var timerid = window.setInterval(function() {/*for (var i = 0; i < 10; i++)*/ Emulator.tick(0);}, 1);
|
||||||
Emulator.mainTickId = timerid;
|
Emulator.mainTickId = timerid;
|
||||||
console.log("Emulator: adding default 1ms (or cheated 0.1 ms) tick with tid=" + timerid);
|
console.log("Emulator: adding default 1ms (or cheated 0.1 ms) tick with tid=" + timerid);
|
||||||
|
|
27
KeyCodes.js
27
KeyCodes.js
|
@ -4,17 +4,26 @@ KeyCodes.normalKey = function(code) {
|
||||||
return String.fromCharCode(code);
|
return String.fromCharCode(code);
|
||||||
}
|
}
|
||||||
KeyCodes.isBackspace = function(code) {
|
KeyCodes.isBackspace = function(code) {
|
||||||
if (code == 8)
|
return (code == 8);
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
KeyCodes.isDelete = function(code) {
|
KeyCodes.isDelete = function(code) {
|
||||||
if (code == 46)
|
return (code == 46);
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
KeyCodes.isEnter = function(code) {
|
KeyCodes.isEnter = function(code) {
|
||||||
if (code == 13)
|
return (code == 13);
|
||||||
return true;
|
}
|
||||||
return false;
|
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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue