Quick Start
The fastest way to get you going.
Install
- NPM
- Bun
- Yarn
yarn add react-hotkeys-hook
npm i react-hotkeys-hook --save
bun i 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 'a' key {count} times.</span> ); }
Result
Loading...
Out of the box support for TypeScript
react-hotkeys-hook
is written in TypeScript, so we don't have to install any additional typings.