How do you submit a form when Enter key is pressed?
In vanilla JavaScript, you can bind an event handler to the keyup event using the addEventListener() method and use the KeyboardEvent. code property to determine whether an Enter key is pressed. Finally, trigger the form's submit event on Enter keypress.
Should Enter key submit form?
In most cases, when a user is focused on a form, the Enter key will submit the form. What's good about this is it's a quick shortcut to complete the form and it gives the user all the power — they can submit at any time even if the form is clearly incomplete, the choice is theirs to make.