
Description
react-keyboard is a React wrapper around mousetrap.js that handles keyboard shortcuts in a React application. The README describes it as a declarative library for hotkeys and focus. You define a keyMap, an object whose values are key sequences. A key sequence can be a single key such as left, a combination such as command+k, or an array of commands such as del and backspace. If you need to listen for a particular event type, you can use an object with a combo and an eventType, such as keyup. The README's usage section shows how to use the HotKeys component with a keyMap, and it has Install and Getting started sections. Because the library is a wrapper, it brings mousetrap's key handling into React components. The project is public on GitHub.…
Highlights
- Keyboard shortcuts for React, built on mousetrap.js
- Declarative keyMap
- HotKeys component
- Single keys, combinations and arrays of commands
- Event type set per shortcut
Ratings & Reviews
No ratings yet
Be the first to rate react-keyboard.
People also visit

react-hotkeys
A declarative library for handling hotkeys and focus within a React application
react-keyboard FAQ
What is react-keyboard?
A React library for keyboard shortcuts and hotkeys. It wraps mousetrap.js.
How do I define shortcuts?
With a keyMap, where each value is a key sequence: a single key such as left, a combination such as command+k, or an array of commands.
Can I choose the event type?
Yes. Use an object with combo and eventType, such as keyup, for a particular shortcut.
What component does it provide?
A HotKeys component, which the README's usage example shows with a keyMap.
Is it open source?
Yes. The source is public on GitHub at ruanyl/react-keyboard.
What are the best react-keyboard alternatives?
Popular alternatives to react-keyboard include react-hotkeys, react-keydown and @TanStack/hotkeys. See all react-keyboard alternatives




















