[dojo-contributors] Event handling proposal

Ben Lowery blowery at dojotoolkit.org
Wed Mar 16 09:37:23 EDT 2011


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

[1] http://msdn.microsoft.com/en-us/scriptjunkie/ff928319
[2]
http://closure-library.googlecode.com/svn/docs/class_goog_events_KeyHandler.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20110316/82f93da5/attachment.htm 


More information about the dojo-contributors mailing list