Jeff,

This sample shows the basic concept:

http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/user/client/ui/TextBox.html

It gets more complicated when you need to handle ctrl keys and special
keys across multiple browsers and on multiple platforms (I'm in the
middle of it right now, and I want to kill the Opera developer who
decided to reverse the meanings of ctrlKey and metaKey on the Mac).

This page is a major lifeline for me:

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

Load that page in every operating system / browser combination you
have, press the keys you care about, note the set of information
returned by the keydown and keypress events, then reconcile the
information for all platform combinations.

Here are some GWT methods that you might find helpful if you have to
dig into the underlying native events:

    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;
    }-*/;

Those methods will make more sense as you play with 
http://unixpapa.com/js/testkey.html
and review the accompanying article on http://unixpapa.com/js/key.html.

To use the methods, do something like this:

    char which = getWhich(event.getNativeEvent());

Jim.

On Dec 10, 2:44 pm, Jeff Larsen <[email protected]> wrote:
> Hi, I have a requirement to implement keyboard bindings like Ctrl+N,
> F11 etc. I was wondering how I can go about grabbing these events
> before the browser grabs them.

--

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