Description
react-keydown is a lightweight library for keyboard handling in React. It works as a higher-order component or a decorator that passes keydown events to the wrapped component, or it lets you call methods directly when designated keys are pressed. Components declare which keys they respond to, so the bindings sit next to the code they affect. Bindings are scoped: only the decorated component and its children receive the key events, and only while they appear to be active. The library supports standard modifier key combinations and can handle all keys or only printable keys. The README says it is about 2kb compressed and gzipped, and that it attaches a single keydown listener to the document no matter how many keybindings you specify. It works in all browsers except IE 8 and below. The README includes install and usage sections for both methods and classes, and a caveat about input, textarea and select elements.…
Highlights
- Higher-order component or decorator
- Declarative key bindings for methods
- Scoped to the component and its children
- Modifier key combinations
- About 2kb with one document listener
Ratings & Reviews
No ratings yet
Be the first to rate react-keydown.
People also visit

react-keyboard
A declarative library for handling hotkeys and focus within a React application

react-hotkeys
A declarative library for handling hotkeys and focus within a React application

@codler/react-native-keyboard-aware-scroll-view
A React Native ScrollView component that resizes when the keyboard appears

react-native-keyboard-aware-scroll-view
A React Native ScrollView component that resizes when the keyboard appears

react-native-keyboard-accessory
A React Native Keyboard Accessory (View, Navigation) Component
react-keydown FAQ
What does react-keydown do?
It passes keydown events to React components, or calls their methods when designated keys are pressed.
How big is it?
The README says it is about 2kb compressed and gzipped.
Does it support modifier keys?
Yes. The README says it supports standard modifier key combinations.
Which browsers are supported?
The README says it works in all browsers except IE 8 and below.
Are there any caveats?
Yes. The README has a caveat section about input, textarea and select elements.
What are the best react-keydown alternatives?
Popular alternatives to react-keydown include react-keyboard, react-hotkeys and @TanStack/hotkeys. See all react-keydown alternatives

















