Track pressed keys in RuntimeHost and handle key up events
This commit is contained in:
@@ -3319,6 +3319,8 @@ export class RuntimeHost {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private handleRuntimeKeyDown = (event: KeyboardEvent) => {
|
private handleRuntimeKeyDown = (event: KeyboardEvent) => {
|
||||||
|
this.pressedKeys.add(event.code);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
event.defaultPrevented ||
|
event.defaultPrevented ||
|
||||||
event.repeat ||
|
event.repeat ||
|
||||||
@@ -3337,6 +3339,15 @@ export class RuntimeHost {
|
|||||||
this.toggleManualPause();
|
this.toggleManualPause();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private handleRuntimeKeyUp = (event: KeyboardEvent) => {
|
||||||
|
this.pressedKeys.delete(event.code);
|
||||||
|
};
|
||||||
|
|
||||||
|
private handleRuntimeBlur = () => {
|
||||||
|
this.pressedKeys.clear();
|
||||||
|
this.previousPauseInputActive = false;
|
||||||
|
};
|
||||||
|
|
||||||
private updatePauseInputState() {
|
private updatePauseInputState() {
|
||||||
if (this.runtimeScene === null || !this.sceneReady) {
|
if (this.runtimeScene === null || !this.sceneReady) {
|
||||||
this.previousPauseInputActive = false;
|
this.previousPauseInputActive = false;
|
||||||
@@ -3345,11 +3356,7 @@ export class RuntimeHost {
|
|||||||
|
|
||||||
const pauseInputActive =
|
const pauseInputActive =
|
||||||
resolvePlayerStartPauseInput(
|
resolvePlayerStartPauseInput(
|
||||||
this.activeController?.id === "firstPerson"
|
this.pressedKeys,
|
||||||
? this.firstPersonController["pressedKeys"]
|
|
||||||
: this.activeController?.id === "thirdPerson"
|
|
||||||
? this.thirdPersonController["pressedKeys"]
|
|
||||||
: new Set<string>(),
|
|
||||||
this.runtimeScene.playerInputBindings
|
this.runtimeScene.playerInputBindings
|
||||||
) >= 0.5;
|
) >= 0.5;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user