fix : hotkey to flip the board
This commit is contained in:
@@ -2,23 +2,24 @@ import { useSetAtom } from "jotai";
|
||||
import { boardOrientationAtom } from "../states";
|
||||
import { IconButton, Tooltip } from "@mui/material";
|
||||
import { Icon } from "@iconify/react";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export default function FlipBoardButton() {
|
||||
const setBoardOrientation = useSetAtom(boardOrientationAtom);
|
||||
|
||||
useEffect(() => {
|
||||
const onKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === "f") {
|
||||
setBoardOrientation((prev) => !prev);
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
const onKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === "f") {
|
||||
setBoardOrientation((prev) => !prev);
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", onKeyDown);
|
||||
window.addEventListener("keydown", onKeyDown);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("keydown", onKeyDown);
|
||||
};
|
||||
}, []);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", onKeyDown);
|
||||
};
|
||||
}, [setBoardOrientation]);
|
||||
|
||||
return (
|
||||
<Tooltip title="Flip board">
|
||||
|
||||
Reference in New Issue
Block a user