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

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 UTC