Skip to content

Instantly share code, notes, and snippets.

@nelix
Created February 5, 2015 02:27
Show Gist options
  • Save nelix/8471de379e60e097c23f to your computer and use it in GitHub Desktop.
Save nelix/8471de379e60e097c23f to your computer and use it in GitHub Desktop.
var React = require('react');
var KeyMixin = require('./');
var Example = module.exports = React.createClass({
displayName: 'KeyMixinExample',
mixins: [KeyMixin],
statics: {
hotKeys: [
{
mask: {key: 'Enter', metaKey: true, altKey: false}, //osx
cb: 'handleEnter',
},{
mask: {key: 'Enter', ctrlKey: true, altKey: false}, //windows
cb: 'handleEnter',
},{
mask: {key: 'Escape', ctrlKey: false, altKey: false},
cb: 'handleEscape',
},
]
},
handleEscape(e) {
alert('escape');
},
handleEnter(e) {
alert('enter');
},
render() {
return (
<input
{...this.callOnKeyDown(Example.hotKeys)}
/>
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment