Skip to content

Instantly share code, notes, and snippets.

@KacperKozak
Last active May 4, 2024 12:24
Show Gist options
  • Save KacperKozak/9736160 to your computer and use it in GitHub Desktop.
Save KacperKozak/9736160 to your computer and use it in GitHub Desktop.
[Ctrl] + [Enter] to submit forms
document.body.addEventListener('keydown', (event) => {
if(event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
event.target.form?.submit();
}
});
@Fanoflix
Copy link

Since e.keyCode is deprecated, here is an updated Typescript snippet: ctrl-enter.ts

@KacperKozak
Copy link
Author

You're correct. This snippet is from 9 years ago, but it has been updated now :)

@AkioKiyota
Copy link

beautiful thing i have ever seen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment