Why a button is clicked when a form is submitted?
From the spec:
4.10.22.2 Implicit submission
If the user agent supports letting the user submit a form implicitly (for example, on some platforms hitting the "enter" key while a text field is focused implicitly submits the form), then doing so for a form whose default button has a defined activation behaviour must cause the user agent to run synthetic click activation steps on that default button.
6.3 [synthetic click] Activation
Certain elements in HTML have an activation behaviour, which means that the user can activate them. This triggers a sequence of events dependent on the activation mechanism, and normally culminating in a click event, as described below.
The user agent should allow the user to manually trigger elements that have an activation behaviour, for instance using keyboard or voice input, or through mouse clicks. When the user triggers an element with a defined activation behaviour in a manner other than clicking it, the default action of the interaction event must be to run synthetic click activation steps on the element.
See full script here
So pressing Enter
is processed as saying submit
in your microphone (with a voice input device). Your browser should behave as if the user has clicked the button to process the click event attached functions properly and improve accessibility for those who can't use a mouse.