(In reply to Emilio Cobos Álvarez (:emilio) from comment #18) > The main issue is that `preventDefault` on `keydown` doesn't seem to prevent the button activation. On `keyup` it does though. > > Do you know what the right behavior is here Masayuki? It's out of scope of any standards. Nothing defines what is default action(s) of `keydown` event, and how to move focus with events. We do it at `keyup` event of space char input: https://searchfox.org/mozilla-central/rev/1ba472c91bbde4b127f6e614ae72888ab59611cf/dom/html/HTMLButtonElement.cpp#239-242 https://searchfox.org/mozilla-central/rev/1ba472c91bbde4b127f6e614ae72888ab59611cf/dom/html/HTMLInputElement.cpp#3772-3773,3793-3794 but we don't check the active state of the element, and it seems that we only set active state only when `mousedown`. https://searchfox.org/mozilla-central/search?q=symbol:_ZN7mozilla17EventStateManager16SetActiveManagerEPS0_P10nsIContent&redirect=false So, it seems that we have different "active" state handling, and it requires for `keyup` handling of the space key.
Bug 1481400 Comment 22 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
(In reply to Emilio Cobos Álvarez (:emilio) from comment #18) > The main issue is that `preventDefault` on `keydown` doesn't seem to prevent the button activation. On `keyup` it does though. > > Do you know what the right behavior is here Masayuki? It's out of scope of any standards. Nothing defines what is default action(s) of `keydown` event, and how to move focus with events. We do it at `keyup` event of space char input: https://searchfox.org/mozilla-central/rev/1ba472c91bbde4b127f6e614ae72888ab59611cf/dom/html/HTMLButtonElement.cpp#239-242 https://searchfox.org/mozilla-central/rev/1ba472c91bbde4b127f6e614ae72888ab59611cf/dom/html/HTMLInputElement.cpp#3772-3773,3793-3794 but we don't check the active state of the element, and it seems that we only set active state only when `mousedown`. https://searchfox.org/mozilla-central/search?q=symbol:_ZN7mozilla17EventStateManager16SetActiveManagerEPS0_P10nsIContent&redirect=false So, it seems that we have different "active" state handling, and it's required for `keyup` handling of the space key.