Skip to main content
Version: 5.0

Quick Start

Get up and running with keyboard shortcuts in under a minute.

Install

npm 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 the 'a' key {count} times.</span>
  );
}
Result
Loading...
TypeScript support out of the box

react-hotkeys-hook is written in TypeScript — no additional @types package needed.