[dojo-contributors] Event handling proposal

Bill Keese bill at dojotoolkit.org
Wed Mar 16 21:14:41 EDT 2011

I don't see how having a KeyHandler class helps us, but I'll take your word
for it.   IIRC, a few years ago Scott Miles suggested an API where you
register separately for each key you want to follow, and it would do the
right thing, listening to keydown or keypress, depending on what you were
monitoring and the browser.

In any case, unfortunately we still need to maintain the old API until 2.x,
but we could add a new one.

2011/3/16 Ben Lowery <blowery at dojotoolkit.org>

> - 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
> _______________________________________________
> dojo-contributors mailing list
> dojo-contributors at mail.dojotoolkit.org
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20110317/33795648/attachment.htm 

More information about the dojo-contributors mailing list