feat(qualification): add aim trainer restart keybind
This commit is contained in:
parent
891e235397
commit
cfa29a64ea
1 changed files with 13 additions and 0 deletions
|
|
@ -315,6 +315,11 @@ export function AimTrainerGame({
|
||||||
}
|
}
|
||||||
}, [resetToReady, startGame]);
|
}, [resetToReady, startGame]);
|
||||||
|
|
||||||
|
const handleRestartAction = useCallback(() => {
|
||||||
|
if (phaseRef.current !== "playing") return;
|
||||||
|
startGame();
|
||||||
|
}, [startGame]);
|
||||||
|
|
||||||
const handleShot = useCallback(
|
const handleShot = useCallback(
|
||||||
(event: PointerEvent<HTMLCanvasElement>) => {
|
(event: PointerEvent<HTMLCanvasElement>) => {
|
||||||
if (event.button !== 0 || phaseRef.current !== "playing") return;
|
if (event.button !== 0 || phaseRef.current !== "playing") return;
|
||||||
|
|
@ -477,6 +482,13 @@ export function AimTrainerGame({
|
||||||
|
|
||||||
raf = requestAnimationFrame(step);
|
raf = requestAnimationFrame(step);
|
||||||
const onKeyDown = (event: KeyboardEvent) => {
|
const onKeyDown = (event: KeyboardEvent) => {
|
||||||
|
if (event.code === "KeyR") {
|
||||||
|
if (event.repeat || event.ctrlKey || event.metaKey || event.altKey) return;
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
handleRestartAction();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (event.code !== "Enter" && event.code !== "Space") return;
|
if (event.code !== "Enter" && event.code !== "Space") return;
|
||||||
if (event.repeat) return;
|
if (event.repeat) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
@ -502,6 +514,7 @@ export function AimTrainerGame({
|
||||||
config.targetLifetimeMs,
|
config.targetLifetimeMs,
|
||||||
difficulty,
|
difficulty,
|
||||||
handlePrimaryAction,
|
handlePrimaryAction,
|
||||||
|
handleRestartAction,
|
||||||
setPhaseSafe,
|
setPhaseSafe,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue