before Unified API
This commit is contained in:
@@ -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") {
|
||||
|
||||
Reference in New Issue
Block a user