W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2012

Re: Where should UA insert text when the focus is changed in a keypress event handler?

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Tue, 20 Mar 2012 15:02:35 -0400
Message-ID: <4F68D44B.7030408@mit.edu>
To: public-webapps@w3.org
On 3/20/12 2:58 PM, Ojan Vafai wrote:
> With my web developer hat on, I would expect the WebKit/IE behavior.
> Keypress is fired before the DOM is modified (I tested in Gecko and
> WebKit on an input element). As such, I'd expect focus changed during a
> keypress event to change where the text is inserted. Notably, Gecko does
> the WebKit/IE behavior if you use keydown instead of keypress. I don't
> see any reason keypress should be different from keydown.

It's different because if you want to express default actions in terms 
of, say, system event group event handlers, the default action 
corresponds to an event handler for the keypress event... and the 
keypress event fired on the input the focus was shifted from.

This is also why it differs from keydown; shifting focus on keydown 
changes the target of the keypress.

-Boris
Received on Tuesday, 20 March 2012 19:03:04 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:50 GMT