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:
parent
9e391a90d9
commit
43989cf299
1 changed files with 6 additions and 1 deletions
|
@ -29,6 +29,10 @@ class Keyboard extends EventEmitter
|
||||||
handleKeyDown(event) {
|
handleKeyDown(event) {
|
||||||
if(!this.DownKeys.includes(event.keyCode))
|
if(!this.DownKeys.includes(event.keyCode))
|
||||||
this.DownKeys.push(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,6 +43,7 @@ class Keyboard extends EventEmitter
|
||||||
if(this.DownKeys.indexOf(event.keyCode) !== -1)
|
if(this.DownKeys.indexOf(event.keyCode) !== -1)
|
||||||
this.DownKeys.splice(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)}`);
|
console.debug("[keyboard] Emitting key up event", `keyup-${keycode(event.keyCode)}`);
|
||||||
this.emit(`keyup-${keycode(event.keyCode)}`, event);
|
this.emit(`keyup-${keycode(event.keyCode)}`, event);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue