I’m confused by the ordering of event listeners in Javascript. If I have a form with a submit button and I’d like to alert a user instead of automatically submitting the form, but only when the submit using the Enter key, I can create an event listener for an Enter keypress, event.preventDefault(), etc.
Why is it that the default onsubmit
event listener for the form is not triggered first?