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