React wrapper for Keypress.js
This library is a react wrapper around the excellent Keypress.js https://dmauro.github.io/Keypress/.
npm install --save keypress-react
This library has 3 public components.
-
KeyboardShortcutsProvider
is the Context Provider Componentimport { KeyboardShortcutsProvider } from 'keypress-react'
This should be at the top of the component tree for which you want to enable shortcuts. It passes the keyboard shortcut context down to your app. All the keyboard shortcut are store in this context.
-
KeyboardShortcut
is the Shortcut Componentimport { KeyboardShortcut } from 'keypress-react'
This component take the props
combo
along with thecallback
and thedescription
.<KeyboardShortcuts combo="shift a" callback={callback} description="Example Shortcut" />
-
withKeyboardShortcuts
is the HOC Componentimport { withKeyboardShortcuts } from 'keypress-react'
This is a higher order components. This will inject a prop
keyboardShortcuts
into the provided component. This props contains all the keyboard shortcuts. It is an array of objects with value and description keys.withKeyboardShortcuts(Component)
MIT © [Govind N Sharma](https://github.com/Govind N Sharma)