RE

React Hotkeys Hook

react-hotkeys-hook

React hook for handling keyboard shortcuts

Hooks
react
hook
hooks
component
hotkey
shortcut
keyboard
shortcuts
keypress
hotkeys
Stars
3.5k
Weekly
2.8M
Open issues
58
Bundle
~25 kB

Installation

npm install react-hotkeys-hook

Code example

import { useHotkeysHook } from "react-hotkeys-hook";

export function Example() {
  const value = useHotkeysHook();
  return <p>{String(value)}</p>;
}

Pros & cons

Pros

  • Actively maintained by Johannes Klauss
  • 2.8M weekly downloads. Battle tested
  • First-class TypeScript definitions
  • MIT licensed

Considerations

  • Adds roughly ~25 kB to your bundle
  • Needs client-only rendering in SSR frameworks
  • Not supported in React Native
  • 58 open issues on GitHub

FAQs

Alternatives & similar libraries