react-hotkey
A simple mixin for application hotkeys.
Provides a react synthetic event to the named event handler, but only when the component is mounted.
For more info, check out the demo from the example folder.
Install
npm install react-hotkey --save
As of version 0.7.0, React 15.4+ is required. If you're using an older version of react, then you should stick with 0.6.0.
Usage
var hotkey = ;// Enable event listening, can be safely called multiple timeshotkey;// The default is to listen for 'keyup' but you can listen to others by passing an argumenthotkey; React
React Mixins do not work with ES2015. Instead one may use the addHandler
and removeHandler
functions:
;;hotkey; Component { thishotkeyHandler = thishandleHotkey; } { console; } { hotkey; } { hotkey; }
Acknowledgements
This approach was extracted from react-bootstrap.
License
MIT