Tuesday, August 5, 2025

Re: Don't use the GWT mouse button constants with Elemental2

Thanks Jens.  Interesting that elemental2.dom.KeyboardEvent doesn't include keyCode or charCode.  I guess that's a good thing, so you can't use deprecated attributes.

On Monday, 4 August 2025 at 7:17:50 pm UTC+10 Jens wrote:
The keyboard key code constants are also old in GWT, but that one was obvious, as GWT has key codes as integers, while Elemental2 has key codes as strings.

JS KeyboardEvent has 

- key (number, the physical key on the keyboard)
- code (string, the final character on the keyboard after evaluating locale, keyboard layout and SHIFT / ALT / CTRL)
- keyCode (number, deprecated, the number does not represent the final character)
- charCode (number, deprecated, only available during keyPress event)

GWT uses keyCode for legacy reasons. You should always use code/key. But even if you use code/key you still have to take care if your application is international. A classic one is ALT + "/" as a keyboard shortcut which I cannot trigger at all for example.


-- J.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-web-toolkit/411462b8-032e-410b-80c1-a50cf81cc494n%40googlegroups.com.

No comments:

Post a Comment