Last active
May 4, 2024 12:24
-
-
Save KacperKozak/9736160 to your computer and use it in GitHub Desktop.
[Ctrl] + [Enter] to submit forms
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
document.body.addEventListener('keydown', (event) => { | |
if(event.key === "Enter" && (event.metaKey || event.ctrlKey)) { | |
event.target.form?.submit(); | |
} | |
}); |
thank you
Most examples use JQuery, props for sharing a pure JS solution :)
Since e.keyCode
is deprecated, here is an updated Typescript snippet: ctrl-enter.ts
You're correct. This snippet is from 9 years ago, but it has been updated now :)
beautiful thing i have ever seen
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple. Beautiful. Quick.