Thomas,

Alan is writing low level code that needs to deal correctly with key
repeats in all browsers.  Sadly, this requires writing browser-
specific code that does some detailed parsing of the keydown and
keypress events.

This article provides some good background:

http://unixpapa.com/js/key.html

And the associated test page is a convenient way to see what events a
browser fires for each key:

http://unixpapa.com/js/testkey.html

One simple example:

Open that page in Firefox.
Press the right arrow key long enough to trigger key-repeat.
Note the stream of events.
Do the same in Chrome; note the different stream of events.

PPK's notes are out of date, but still useful:

http://www.quirksmode.org/js/keys.html

Bottom line:  Writing low level JavaScript code to manage keystrokes
is a challenge.  The GWT documentation notes that there are no
coherent browser standards in this area:

http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/event/dom/client/KeyEvent.html
"The native keyboard events are somewhat a mess (http://
www.quirksmode.org/js/keys.html), we do some trivial normalization
here, but do not attempt any complex patching, so user be warned."

On Feb 14, 4:15 am, Thomas Broyer <[email protected]> wrote:
> On Feb 14, 1:29 am, AB <[email protected]> wrote:
>
> > The newish event handler system seems designed to prevent getting a
> > keycode from the KeyDown and KeyUp events?
>
> You mean a char code? or KeyPress event?
>
> > Does anyone know the reasoning behind this?
>
> Key down/up events are designed for keys, not chars, contrary to
> keypress.
>
> > This creates a problem. For example, in IE, if one wants to detect
> > autorepeats of a non char key like an uparrow, you only get it on a
> > KeyDown event (seehttp://unixpapa.com/js/key.html). Since the
> > KeyPress does not get repeats (in IE for arrow keys), I need an
> > KeyDown event handler that knows they key that was hit (maybe i could
> > write enough logic to first sense the keypress, then remember that
> > keycode,...)
>
> OK, so you seem to really be talking about KeyDown/KeyUp and key code
> (arrow keys).
>
> Have you looked at the events' getNativeKeyCode() method and the
> KeyCodes class?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to