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", (e: KeyboardEvent) => { | |
if (!(e.key === "Enter" && (e.metaKey || e.ctrlKey))) return | |
if ('form' in e.target) { | |
const formElement = e.target.form as HTMLFormElement; | |
formElement?.submit(); // or formElement?.requestSubmit() depending on your usecase | |
} | |
}) | |
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(); | |
} | |
}); |