Last active
July 8, 2018 08:14
-
-
Save intermundos/ab10c79726cb7773ffb9212e9b0d8601 to your computer and use it in GitHub Desktop.
React on Esc event
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
onESCpressed = (e) => { | |
e.keyCode === 27 && some_Func() | |
} | |
componentDidMount() { | |
document.addEventListener('keydown', this.onESCpressed, false) | |
} | |
componentWillUnmount() { | |
document.removeEventListener('keydown', this.onESCpressed, false) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment