@monstermann/react-hotkeys
v0.0.0
Published
React hooks for @monstermann/hotkeys
Downloads
3
Maintainers
Readme
react-hotkeys
React hooks for @monstermann/hotkeys
.
Installation
npm install @monstermann/hotkeys @monstermann/react-hotkeys
pnpm add @monstermann/hotkeys @monstermann/react-hotkeys
yarn add @monstermann/hotkeys @monstermann/react-hotkeys
Usage
import { createHotkeys } from '@monstermann/hotkeys'
import { parseShortcut } from '@monstermann/hotkeys/vscode'
import { createShortcutHook, createShortcutsHook } from '@monstermann/react-hotkeys'
export const hotkeys = createHotkeys()
export const useShortcut = createShortcutHook(hotkeys, parseShortcut)
export const useShortcuts = createShortcutsHook(hotkeys, parseShortcut)
export function Component() {
useShortcut('ctrl+a', callback, bindingContext)
useShortcuts(['ctrl+a', 'meta+a'], callback, bindingContext)
}