refactor: better shortcut hook
This commit is contained in:
13
packages/ui/lib/shortcuts/Provider.web.tsx
Normal file
13
packages/ui/lib/shortcuts/Provider.web.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { keysStore } from "./store";
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
window.addEventListener("keydown", (e) => {
|
||||
const fn = keysStore.getHandler(e.key);
|
||||
fn?.();
|
||||
});
|
||||
}
|
||||
|
||||
export function ShortcutProvider({ children }: { children: ReactNode }) {
|
||||
return children;
|
||||
}
|
||||
Reference in New Issue
Block a user