Skip to content

Instantly share code, notes, and snippets.

@StrongerMyself
Created October 2, 2019 05:50
Show Gist options
  • Save StrongerMyself/f05f177f02c7443d3491d53b02f25c99 to your computer and use it in GitHub Desktop.
Save StrongerMyself/f05f177f02c7443d3491d53b02f25c99 to your computer and use it in GitHub Desktop.
window.onkeydown = function(e) {
if (e.keyCode == 27) {
var focused = document.activeElement;
if (focused.tagName == 'INPUT' || focused.tagName == 'TEXTAREA') {
focused['blur']()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment