-
-
Save nocodesupplyco/8616fd3e88f351f7aca0472bcb8904a9 to your computer and use it in GitHub Desktop.
Click Something When Pressing ESC Key
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
/* Update .class with the class of element you wish to click */ | |
document.body.addEventListener('keydown', function (e) { | |
if (e.key === 'Escape') { | |
document.querySelector('.class').click(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment