refactor: better shortcut hook

This commit is contained in:
Max Koon
2025-12-05 17:05:23 -05:00
parent 2df7f2d924
commit 76f2a43bd0
21 changed files with 481 additions and 143 deletions

View File

@@ -0,0 +1,14 @@
import { useEffect, useRef } from "react";
import { keysStore } from "./store";
export const useShortcut = (key: string, handler: () => void) => {
const ref = useRef(handler);
ref.current = handler;
useEffect(() => {
keysStore.register(key, ref);
return () => {
keysStore.deregister(key);
};
}, []);
};