You can use onKeyPress which will give you the character. Key up/down gives you the key code not the character code. If you want the character, you have to amend the key code by checking the shift/alt gr/alt/ctrl and any other keys that might affect what you are trying to get.
Ian http://examples.roughian.com 2009/8/21 Rakesh <[email protected]> > > Thomas, I am not sure I understand what you are saying. I need the > last char pressed by the user(on key down/up). How do you get that? > > On Aug 14, 6:31 pm, Thomas Broyer <[email protected]> wrote: > > On 14 août, 21:37,rakeshwagh<[email protected]> wrote: > > > > > > > > > Today While extending the TextBox, I encountered very strange > > > behaviour. > > > All alphabets returned by event.getNativeKeyCode() are upper case. > > > Here is sample program: > > > > > public class TextBox extends com.google.gwt.user.client.ui.TextBox{ > > > public TextBox() { > > > super(); > > > addKeyDownHandler(new KeyDownHandler(){ > > > public void onKeyDown(KeyDownEvent > event) { > > > int key = > event.getNativeKeyCode(); > > > System.out.println("key: " + > (char)key); > > > } > > > } > > > } > > > > > } > > > > > Enter characters in lower case, it will print upper case to the > > > console. I thought of checking with the group before raising it as an > > > issue. Any idea on what's going on here? > > > > You're confusing "key codes" with "characters". Key codes (as well as > > keydown and keyup events) are really about keyboard *keys* that you > > depress (or at least should be, as it differs a bit amongst browsers). > > > > This was really confusing in GWT 1.5 and previous versions, since GWT > > 1.6 and the new events, it's a bit clearer, but still somewhat buggy > > (see issue 3753: > http://code.google.com/p/google-web-toolkit/issues/detail?id=3753 > > ) > > > > See also issues 72 (among others): > http://code.google.com/p/google-web-toolkit/issues/detail?id=72 > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
