W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2011

Re: [DOM3Events] keydown/keyup asymmetry for held keys (key repeating)

From: Ojan Vafai <ojan@chromium.org>
Date: Wed, 22 Jun 2011 11:33:23 -0700
Message-ID: <BANLkTim_F0V9i3r3oTVLQrL2nP60OsWH2w@mail.gmail.com>
To: "L. David Baron" <dbaron@dbaron.org>
Cc: www-dom@w3.org
While I agree that having keydown/keyup be symmetric would be a better API,
every browser currently implements it repeating keydown events. I don't
think we could change this without taking a significant compatibility hit.

On Wed, Jun 22, 2011 at 11:25 AM, L. David Baron <dbaron@dbaron.org> wrote:

> http://www.w3.org/TR/DOM-Level-3-Events/#events-keyboardevents says:
>  # Holding down a key must result in the repeating the events
>  # keydown, keypress (when supported by the user agent), and
>  # textinput (when the keypress results in text input) in this
>  # order, at a rate determined by the system configuration.
>
> I think this is a bad idea because it introduces asymmetry between
> the keydown and keyup events (which I think authors would reasonably
> expect to be symmetric) and because it defines keydown in a way that
> also violates a reasonable expectation -- that it be fired when the
> key is pressed (just like the existing "mousedown" event).
>
> Instead, I propose that key repetition be handled by repetitions of
> the keypress and textinput events, but that the keydown event not
> repeat.
>
> Changing this would also require that the keypress event fire for
> keys that do not produce a character value (e.g., arrow keys,
> backspace), which
> http://www.w3.org/TR/DOM-Level-3-Events/#events-keyboard-event-order
> says is not the case, since authors do need to detect repetitions of
> those keys.
>
> -David
>
> --
> L. David Baron                                 http://dbaron.org/
> Mozilla Corporation                       http://www.mozilla.com/
>
>
Received on Wednesday, 22 June 2011 18:34:07 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:07 GMT