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

textInput event as default action of both keydown and keypress?

From: Hallvord R. M. Steen <hallvord@opera.com>
Date: Wed, 22 Sep 2010 13:37:59 +0900
To: www-dom@w3.org
Message-ID: <op.vje25l2da3v5gv@hr-opera>
Hi,
spec currently says about keydown event:

> if the key is associated with a character, the default action
> shall be to dispatch a textInput event with the character as
> the value of the TextEvent.data attribute

and about the keypress event (in the table):

> Default action	Varies: textInput event;

So an implementation that follows this spec to the T might end up firing  
textInput twice for all input, once as the default action of keydown and  
once as the default action of keypress..

What implementations actually do (and current web content requires) is to  
fire *keypress* as the default action of the keydown event. Then the  
keypress event's default action is to fire textInput.

I suggest fixing the spec to say keydown's default action is a keypress  
event.

(Firefox has a small quirk that the spec IMO can ignore in that  
preventDefault() on keydown doesn't actually prevend the keypress event  
 from firing - but it fires "pre-cancelled". At some point in time, some  
legacy content required this behaviour - but other browsers align on  
making keypress entirely preventable.)

-- 
Hallvord R. M. Steen, Core Tester, Opera Software
http://www.opera.com http://my.opera.com/hallvors/
Received on Wednesday, 22 September 2010 04:38:22 GMT

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