RFR: 8273743: KeyCharacterCombination for "+" does not work on US QWERTY keyboard layout [v3]

Martin Fox duke at openjdk.java.net
Mon Dec 6 01:38:09 UTC 2021


On Wed, 10 Nov 2021 18:48:04 GMT, Martin Fox <duke at openjdk.java.net> wrote:

>> There was a mismatch between the way `get_glass_key` generated the Java key code for a given key press and how `getKeyCodeForChar` determined the key code for the matching character. For example, when pressing the plus sign on a US keyboard `get_glass_key` correctly generated `KeyCode.EQUALS` but `getKeyCodeForChar("+")` generated `KeyCode.PLUS`.
>> 
>> In this PR `getKeyCodeForChar` mirrors the behavior of `get_glass_key`; it determines which key the character lies on and generates a key code based on the unshifted character on  the same key.
>> 
>> I'm working on a more comprehensive test case that allows you to press any key on the keyboard and test whether a KeyCharacterCombination for that character will succeed or not. I've attached it to this thread. It might be worth submitting as a manual test case
>> [CharComboTest.txt](https://github.com/openjdk/jfx/files/7247265/CharComboTest.txt)
>> .
>
> Martin Fox has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Remove extraneous whitespace

Gdk is finding these three characters (comma, left paren, right paren) on the main keyboard using the Shift modifier and on the keypad without Shift. Presumably there are keyboards out there which have some or all of these characters on the keypad and those keys were incorporated into the US keymap (but not French, Russian, or German). Most keys on the keypad have distinct keyvals but not these, they share the same keyvals as the keys on the main keyboard.

I'll continue to investigate but this just reinforces my conviction that `KeyCharacterCombination` should be re-engineered. The current approach requires mapping backward from a character to a key which is difficult to do on every platform except Windows (where it's still tricky, see #672) and the requirement that each character maps to just one key is inherently limiting.

-------------

PR: https://git.openjdk.java.net/jfx/pull/635


More information about the openjfx-dev mailing list