react-shortcut-key
Shortcut key wrapper for react components.
Install
npm install react-shortcut-key
Usage
// Define callback functions of shortcut keyconst componentOnHello = const componentOnBye = // Define shortcut key map.const keymap = 'ctrl+enter': componentOnHello 'meta+esc': componentOnBye // Any component which will use shortcut keysComponent { return <div>Press "CTRL + Enter" or "CTRL + Esc" to alert messages</div> } // Inject the shortcut keys into the componentconst ComponentWithHotkey = Component // render DOMconst rootNode = documentdocumentbodyReactDOM