On 27 avr, 10:18, Flueras Bogdan <[email protected]> wrote:
> On any french keyboard(AZERTY)
> - the dot char '.' is generated with (Shift + ;) combination
> - the percent char '%' is generated with (Shift + ù) combination
>
> So when I type one of the above combinations to write '.' or ' %', the
> key codes generated for these events are KEY_DELETE in the former case
> and KEY_LEFT in the latter.
>
> Code snippet:
> TextArea txtArea = new TextArea();
> txtArea.addKeyPressHandler(new KeyPressHandler() {
>             public void onKeyPress(KeyPressEvent event)
> {
>                 switch (charCode) {
>                     case KeyCodes.KEY_LEFT: { // key code 37
>                         System.out.write("KEY LEFT");
>                         break;
>                     }
>                     case KeyCodes.KEY_DELETE: {   // key code
> 46
>                          System.out.write("DELETE");
>                          break;
>                     }
>                 }
>
> Workaround:  get charCode and do a character match like this:
>
> charCode = event.getCharCode();
> if (charCode == '.') {...}
> else if (charCode == '%') {...}

or:
switch (event.getCharCode()) {
case '.':
   ...
   break;
case '%':
   ...
   break;
}

> Is this a GWT bug ?

No. KeyPress deals with characters whereas KeyDown and KeyUp deal with
"physical keys".

Note that the following change will be shipped in the next GWT version
(2.1):
http://gwt-code-reviews.appspot.com/154812
which fixes issue 3753:
http://code.google.com/p/google-web-toolkit/issues/detail?id=3753
But there are many other issues with keyboard events, as the KeyEvent
JavaDoc warns: """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."""

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