1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

move KeyMouse listeners to correct location

This commit is contained in:
Dimava
2020-06-01 02:36:41 +03:00
parent fe33f51424
commit 0d342ee417
2 changed files with 9 additions and 6 deletions

View File

@@ -141,8 +141,13 @@ export class InputDistributor {
bindToEvents() {
window.addEventListener("popstate", this.handleBackButton.bind(this), false);
document.addEventListener("backbutton", this.handleBackButton.bind(this), false);
window.addEventListener("keydown", this.handleKeydown.bind(this));
window.addEventListener("keyup", this.handleKeyup.bind(this));
window.addEventListener("keydown", this.handleKeyMouseDown.bind(this));
window.addEventListener("keyup", this.handleKeyMouseUp.bind(this));
window.addEventListener("mousedown", this.handleKeyMouseDown.bind(this));
window.addEventListener("mouseup", this.handleKeyMouseUp.bind(this));
window.addEventListener("blur", this.handleBlur.bind(this));
}
@@ -184,7 +189,7 @@ export class InputDistributor {
/**
* @param {KeyboardEvent | MouseEvent} event
*/
handleKeydown(event) {
handleKeyMouseDown(event) {
const keyCode = event instanceof MouseEvent ? event.button + 1 : event.keyCode;
if (
keyCode === 4 || // MB4
@@ -224,7 +229,7 @@ export class InputDistributor {
/**
* @param {KeyboardEvent | MouseEvent} event
*/
handleKeyup(event) {
handleKeyMouseUp(event) {
const keyCode = event instanceof MouseEvent ? event.button + 1 : event.keyCode;
this.keysDown.delete(keyCode);