Skip to content

Instantly share code, notes, and snippets.

@bingeboy
Last active Nov 3, 2015
Embed
What would you like to do?
/**
* Handler for keyDown
* @description if ESC key is clicked close modal
* @param {object} e - SyntheticKeyboardEvent
* @return {undefined} undefined
*/
_handleKeyDown: function (e) {
if (e.keyCode === 27) {
this._handleModalClose();
}
},
...
/**
* Render
* @returns {ReactElement} react element
*/
render: function () {
return (
<div className="site-header" onKeyDown={this._handleKeyDown}>
<header role='banner'>
{this.props.children}
</header>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment