mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 23:15:36 +00:00
refactor: create shortcut hook that with default config
This commit is contained in:
11
inertia/hooks/use_shortcut.tsx
Normal file
11
inertia/hooks/use_shortcut.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import KEYS from '#constants/keys';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
import useGlobalHotkeys from '~/hooks/use_global_hotkeys';
|
||||
|
||||
export default function useShortcut(key: keyof typeof KEYS, cb: () => void) {
|
||||
const { globalHotkeysEnabled } = useGlobalHotkeys();
|
||||
return useHotkeys(KEYS[key], cb, {
|
||||
enabled: globalHotkeysEnabled,
|
||||
enableOnFormTags: ['INPUT'],
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user