Quick start
Install the package and add a keyboard shortcut to a React component.
Install
- pnpm
- bun
- npm
- yarn
pnpm add react-hotkeys-hook
bun add react-hotkeys-hook
npm install react-hotkeys-hook
yarn add react-hotkeys-hook
Usage
import { useHotkeys } from 'react-hotkeys-hook'
Live Editor
function MyComponent() { const [count, setCount] = useState(0) useHotkeys('a', () => setCount((count) => count + 1)) return <span>Pressed the 'a' key {count} times.</span> }
Result
Loading...