[BUG} Trying fix pressing buttons out of focus
This commit is contained in:
parent
b4f1e7c083
commit
e90a424e54
@ -1,4 +1,4 @@
|
||||
import { GameField } from "./Graphics/gameField";
|
||||
import { GameField } from "./GameLogic/gameField";
|
||||
import { TankKeyAdapter } from "./KeyAdapters/tankKeyAdapter";
|
||||
|
||||
export function init() {
|
||||
@ -20,6 +20,11 @@ export class Game {
|
||||
let prevEv;
|
||||
let holding = (ev) => {
|
||||
if (!prevEv || prevEv.key != ev.key) return;
|
||||
if (document.visibilityState == "hidden") {
|
||||
alert("I'm hidden");
|
||||
prevEv = undefined;
|
||||
return;
|
||||
}
|
||||
this.gameKeyAdapter.handleEvent(ev)
|
||||
requestAnimationFrame(() => holding(ev));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user