refactor: global keys

This commit is contained in:
cha0s 2019-04-29 18:03:46 -05:00
parent 49080972b4
commit 103140ee8f

View File

@ -90,8 +90,7 @@ export class App extends decorate(class {}) {
this.onBlur = this.onBlur.bind(this);
this.onFocus = this.onFocus.bind(this);
// Global keys.
this.onGlobalKeydown = this.onGlobalKeydown.bind(this);
window.addEventListener('keydown', this.onGlobalKeydown);
this.inputNormalizer.on('keyDown', this.onGlobalKeydown, this);
this.pointingAt = [-1, -1];
this.pointerMovementHandle = undefined;
// Net.
@ -236,8 +235,8 @@ export class App extends decorate(class {}) {
this.isFocused = true;
}
onGlobalKeydown(event) {
switch (event.key) {
onGlobalKeydown(key) {
switch (key) {
case 'F2':
this.isDebugging = !this.isDebugging;
break;