Skip to content

Instantly share code, notes, and snippets.

@bingeboy
Last active November 3, 2015 13:56
Show Gist options
  • Save bingeboy/e88cb7d1a39ec5841945 to your computer and use it in GitHub Desktop.
Save bingeboy/e88cb7d1a39ec5841945 to your computer and use it in GitHub Desktop.
/**
* 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