[dojo-contributors] Event handling proposal

Kris Zyp kzyp at dojotoolkit.org
Wed Mar 16 10:36:06 EDT 2011

On 3/16/2011 7:37 AM, Ben Lowery wrote:
>         - keypress handling - this is moved out to dojo/_base/keypress.js as a
>         custom extension/emulation event.
>     Didn't quite follow the code in keypress.js, I know for IE you
>     need to generate faux keypress events for non-printable characters
>     (otherwise you just get a keydown event), but it looks like you
>     are listening for keypress events in order to generate keypress
>     events:
>     return listen(object, "keypress", function(evt){
>     ...
>     // simulate a keypress event
>     var faux = _synthesizeEvent(evt, {type: 'keypress', faux: true, charCode: c});
> We might want to take this opportunity fix our key handling. I did
> some poking around a bit ago, and wrote up my findings for script
> junkie[1]. I think our approach of trying to rationalize key events on
> to the mozilla model isn't a good way to go, it leads to too many
> surprises, especially when you're trying to do something low level. A
> better approach would be to expose a separate key handling
> abstraction, probably comparable to how closure does it [2].
> You really don't want to try to normalize onto either the IE/Webkit or
> the Mozilla model. They differ on how they deal with preventing
> default behavior, how repeats are handled, and a bunch of other little
> things. Also, neither is backed by a standard (there is NO worthwhile
> standard on how key events behave, unless you go to DOM3, and no one
> has bothered to implement that in a serious manner yet).

Exactly, that is why I wanted break this emulation out to an extension,
and avoid automagical application of the emulation in the clean slate
API, dojo/listen. I had assumed that dojo.connect would need to retain
the current emulation behavior for backwards-compatibility. When
dojo.connect was originally written, I am sure siding with Mozilla
seemed the safest bet, but with Webkit siding with IE, this emulation no
longer seems most correct. Event emulation in dojo/listen would be an
explicit choice of the user, and if someone created an emulation event
that standardized IE/WebKit's behavior, they could choose that as well.
If my assumption that backwards compatibility is needed in dojo.connect
is wrong, let me know, that could certainly influence this design.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20110316/146a0c7d/attachment.htm 

More information about the dojo-contributors mailing list