My question is actually more general, but I am using the action of the user holding the "Alt" key and pressing the "+" as an example that shows difficulties.
I work on an English English keyboard with "=" (lowercase letters) and "+" (uppercase) on the same key, so press "Alt +" (as may be indicated in the menu entry), I should on actually press "Alt Shift =". In Java AWT, pressing the Alt Shift = key generates a KeyEvent key press with the key code associated with the = key and the KeyDisc KeyEvent with a ± symbol. Thus, there is no obvious and reliable way to programmatically decide that "Alt" is held down by the "+" key.
I could do some mapping inside to fix this, for example, matching "±" with "Alt +" or mapping "Shift {keycode for =}" to "+". However, there seems to be no guarantee that this will work in different keyboard layouts; and this, of course, is not a very good coding style.
If anyone can suggest a way around these issues, or perhaps point to code that has already dealt with this difficulty, I would be very grateful.
Thanks.
source share