1
0
Fork 0
mirror of https://github.com/sbrl/Nibriboard.git synced 2018-01-10 21:33:49 +00:00

[client] Emit keydown events just like keyup does, and log DownKeys for debugging purposes

This commit is contained in:
Starbeamrainbowlabs 2017-04-24 22:03:23 +01:00
parent 9e391a90d9
commit 43989cf299

View file

@ -29,6 +29,10 @@ class Keyboard extends EventEmitter
handleKeyDown(event) {
if(!this.DownKeys.includes(event.keyCode))
this.DownKeys.push(event.keyCode);
console.log("DownKeys:", this.DownKeys);
console.debug("[keyboard] Emitting key down event", `keydown-${keycode(event.keyCode)}`);
this.emit(`keydown-${keycode(event.keyCode)}`, event);
}
/**
@ -38,7 +42,8 @@ class Keyboard extends EventEmitter
handleKeyUp(event) {
if(this.DownKeys.indexOf(event.keyCode) !== -1)
this.DownKeys.splice(this.DownKeys.indexOf(event.keyCode), 1);
console.log("DownKeys:", this.DownKeys);
console.debug("[keyboard] Emitting key up event", `keyup-${keycode(event.keyCode)}`);
this.emit(`keyup-${keycode(event.keyCode)}`, event);
}