Created
February 5, 2015 02:27
-
-
Save nelix/8471de379e60e097c23f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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