I\'m trying to implement some very basic key press detection and I can\'t get it to work at all. I have a bare component that should be picking up on the onKeyDown
In an app my team is working on, we're using react-hotkey. Unfortunately, React doesn't seem to support mixins with ES6 syntax, but if you're cool with some babel, you could give it a try.
let App = React.createClass({
mixins: [hotkey.Mixin('handleKeyDown')],
componentDidMount() {
hotkey.activate();
},
componentWillUnmount() {
hotkey.disable();
},
handleKeyDown(event) {
console.log('handling a key press');
},
render() {
return (
);
}
});
React.render( , document.getElementById('app'));