You should start by taking a quick look at the source code to see
exactly what value GWT returns for KeyPressEvent.getCharCode(); it
might be different from what you expect.

http://www.google.com/codesearch/p?hl=en#A1edwVHBClQ/user/src/com/google/gwt/event/dom/client/KeyPressEvent.java&q=keypressevent%20package:http://google-web-toolkit%5C.googlecode%5C.com&sa=N&cd=1&ct=rc

You can add a tiny bit of JSNI code to get anything you need from the
key events.  For example, I do this as one part of a check for special
keys:

    public void onKeyPress(KeyPressEvent event)
    {
        char c = event.getCharCode();
        char which = getWhich(event.getNativeEvent());
        if (isOpera() && c == m_keyDown && (c == KEY_HOME ||
                                            c == KEY_END ||
                                            c == KEY_INSERT ||
                                            c == KEY_DELETE))
        which = 0; // I hate Opera. See: http://unixpapa.com/js/key.html


    protected native char getWhich(NativeEvent e)/*-{
      return e.which;
    }-*/;

    protected native char getCharCode(NativeEvent e)/*-{
      return e.charCode;
    }-*/;

    protected native char getKeyCode(NativeEvent e)/*-{
      return e.keyCode;
    }-*/;


On Feb 13, 4:29 pm, AB <[email protected]> wrote:
> The newish event handler system seems designed to prevent getting a
> keycode from the KeyDown and KeyUp events?  Does anyone know the
> reasoning behind this?
> 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,...)

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