RFR: 8087700: [KeyCombination, Mac] KeyCharacterCombinations behave erratically

Andy Goryachev angorya at openjdk.org
Wed Nov 15 23:11:41 UTC 2023


On Mon, 14 Aug 2023 16:28:20 GMT, Martin Fox <mfox at openjdk.org> wrote:

> A KeyCharacterCombination should match a key if the target character is printed on that key. For example, the user should be able to invoke the `Shortcut+'+' ` combination by holding down the Shortcut key and pressing a key that has '+' printed on it. This should work even if '+' is a shifted symbol but the user doesn't hold down the Shift key. 
> 
> The Mac implements KeyCharacterCombinations by monitoring keystrokes to discover the relationship between keys and characters. Currently the system only records the character the user typed and no other characters on the same key. This means a shortcut targeting a shifted character may not work until the user types that character using Shift so the system learns the relationship.
> 
> This PR keeps the same mechanism in place but always records the shifted and unshifted character for each keystroke.
> 
> For the Mac the KeyboardTest app was modified to remove tests for characters accessed using Option. We don't look for these characters because under the hood just about every key has some symbol assigned to the Option modifier that the user probably isn't even aware of. For these character we fall back to the existing logic; once the user types the character it will start working as a shortcut.

All right, so I see "HI" printed twice on macOS and Windows.  I guess we are good here.

A couple of other observations:

1. Using French keyboard on mac (and windows), Ctrl-- is expected to produce the key code RIGHT_PARENTHESIS, correct?

KeyEvent{type=KEY_PRESSED, character=<\u00>, text=, code=CONTROL, control}
KeyEvent{type=KEY_PRESSED, character=<\u00>, text=, code=RIGHT_PARENTHESIS, control}
KeyEvent{type=KEY_TYPED, character=<\u1B>, text=, code=UNDEFINED, control}  <-- missing on Windows, as expected
KeyEvent{type=KEY_RELEASED, character=<\u00>, text=, code=RIGHT_PARENTHESIS, control}
KeyEvent{type=KEY_RELEASED, character=<\u00>, text=, code=CONTROL}


2. Using KeyboardTest, I am getting:

|Layout|w/o combinations|w/o keypad combinations|with all combinations|
|---|---|---|---|
|US|0|0|0

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

PR Comment: https://git.openjdk.org/jfx/pull/1209#issuecomment-1813415079


More information about the openjfx-dev mailing list