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