W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2011

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

From: Hallvord R. M. Steen <hallvord@opera.com>
Date: Fri, 08 Jul 2011 12:48:04 +0900
To: www-dom@w3.org, "L. David Baron" <dbaron@dbaron.org>
Message-ID: <op.vx97ie10a3v5gv@hr-opera.oslo.opera.com>
On Thu, 23 Jun 2011 03:25:41 +0900, 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).

Hi David,
I think some comments from me may have led to the current text in this  
section. Opera is currently doing what you suggest is better (one keydown,  
repeated keypress) and we consider this a bug because it does indeed cause  
us compatibility problems. It breaks stuff as high-profile as Google Docs  
where for example pressing and holding backspace doesn't work as you would  
expect. (I have no idea if that is also a problem in Firefox 3.6 or  
whether G Docs has a workaround that they just don't apply to Opera.)

We intend to fix this and repeat both keydown and keypress for compat  
reasons, and I don't think it's a good idea to spec something we know  
causes compatibility problems for reasons of theoretical purity.

> 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.

Incidentally, this proposal would also break Google Docs in a really,  
really bad way. Been there, done that. Set "Browser JavaScript" to 0 in  
opera:config and load a Docs document to see what happens if you do this..


-- 
Hallvord R. M. Steen, Core Tester, Opera Software
http://www.opera.com http://my.opera.com/hallvors/
Received on Friday, 8 July 2011 03:48:21 GMT

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