Hi,
How do I convert the javascript code "window.onkeyup" (or onkeyup in body tag) to GWT?
Regards
Hi,
How do I convert the javascript code "window.onkeyup" (or onkeyup in body tag) to GWT?
Regards
I think you could do that with KeyboardListener.
There is a good discussion thread about it (and some issues): http://groups.google.com/group/google-web-toolkit/browse%5Fthread/thread/6072c87aa27a2d6e/524334b959683f77
For a page wide listener, you want to take a look at Event.addNativePreviewHandler. Attaching a keyup listener there should give you the effect you want. Modifing the snippet here should get you started:
Event.addNativePreviewHandler(new NativePreviewHandler() {
public void onPreviewNativeEvent(final NativePreviewEvent event) {
final int eventType = event.getTypeInt();
switch (eventType) {
case Event.ONKEYUP:
//magic here
break;
default:
// not interested in other events
}
}
});