keypress-react v1.0.0
keypress-react
React wrapper for Keypress.js
This library is a react wrapper around the excellent Keypress.js https://dmauro.github.io/Keypress/.
Install
npm install --save keypress-react
Usage
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
.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)
License
MIT © Govind N Sharma(https://github.com/Govind N Sharma)
3 years ago