Skip to content

Instantly share code, notes, and snippets.

@ronal2do
Last active October 25, 2016 11:11
Show Gist options
  • Save ronal2do/4b9abbf20f08541adbdf23b456ca1119 to your computer and use it in GitHub Desktop.
Save ronal2do/4b9abbf20f08541adbdf23b456ca1119 to your computer and use it in GitHub Desktop.
componentWillMount() {
global.addEventListener("keyPress", this._handleEscKey, false);
};
componentWillUnmount() {
global.removeEventListener("keyPress", this._handleEscKey, false);
};
_handleEscKey = (event) => {
if(event.keyCode == 27){
this.setState({
isToggleOn: false,
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment