Skip to main content
Version: 5

Quick start

Install the package and add a keyboard shortcut to a React component.

Install​

pnpm 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...