When using <form> tags, it has a built-in behavior for enter key, which runs the submit.
They decided to make it using keydown, so it creates spam issues. For example if I had a form for a todo list, and i hold the enter key then it will spam create the same todo-item.
I want it to be keyup or keypress instead of keydown, I would still like enter key to submit rather than getting rid of it all together.
Using blur() also doesnt work since it doesnt focus on the button in the first place.
<form>
<label>username
<input type="text" />
</label>
<label>password
<input type="text" />
</label>
<button type="submit">Login</button>
</form>
document.querySelector("form").addEventListener("submit", event => {
event.preventDefault();
console.log( "submitted" );
})