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]);
|
||||
|
||||
const handleRestartAction = useCallback(() => {
|
||||
if (phaseRef.current !== "playing") return;
|
||||
startGame();
|
||||
}, [startGame]);
|
||||
|
||||
const handleShot = useCallback(
|
||||
(event: PointerEvent<HTMLCanvasElement>) => {
|
||||
if (event.button !== 0 || phaseRef.current !== "playing") return;
|
||||
|
|
@ -477,6 +482,13 @@ export function AimTrainerGame({
|
|||
|
||||
raf = requestAnimationFrame(step);
|
||||
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.repeat) return;
|
||||
event.preventDefault();
|
||||
|
|
@ -502,6 +514,7 @@ export function AimTrainerGame({
|
|||
config.targetLifetimeMs,
|
||||
difficulty,
|
||||
handlePrimaryAction,
|
||||
handleRestartAction,
|
||||
setPhaseSafe,
|
||||
]);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue