before Unified API

This commit is contained in:
2025-10-30 22:14:04 +00:00
parent 444eb5c6f4
commit 2b3a55df37
3 changed files with 14 additions and 4 deletions
+7 -1
View File
@@ -2,7 +2,7 @@ import { useEffect } from "react";
import type { UseGameType } from "@vimazing/vim-snake";
export const useKeyBindings = (gameManager: UseGameType) => {
const { gameStatus, startGame, stopGame, clearLog, resetCount } = gameManager;
const { gameStatus, startGame, stopGame, clearLog, resetCount, togglePause } = gameManager;
useEffect(() => {
const handler = (ev: KeyboardEvent) => {
@@ -22,6 +22,12 @@ export const useKeyBindings = (gameManager: UseGameType) => {
}
}
console.log('ev.key', ev.key)
if (ev.key === 'p' || ev.key === 'P') {
togglePause();
}
// quit
if (ev.key === "q" || ev.key === "Q") {
if (gameStatus === "started") {