I’m using keystroke events from ButtonThrower to have keyboard agnostic shortcuts in my app, not for the plain alphanumeric keys but the more fancy one like /, =, : and so on which may use modifiers on international keyboard or laptop keyboard to be generated by the user.
It works fine, except that I recently discovered that there is an unexpected behaviour, when the combination of the base key and the modifier does not create a new key, the keystroke event receives only the base key. For example, ‘C’, and ‘Alt-C’ will both generate keystroke event with ‘C’ as keyname
I know about that discussion, I’m using keystrokes from the button thrower instead of key button events to abstracts those inconsistencies across platforms and keyboards.
On my system, if I do a “shift-;” I get a “.” as a keystroke (as this is the character that is generated by that combination) and a “Shift-;” as key button event, and that’s what I’m expecting. However, when doing “Alt-C”, I’m getting “C” as keystroke, which to me is weird as “Alt-C” is not meant to generate a new character and so I thought it wouldn’t generate any keystroke at all.
I’ll test with DirectEntry later as it is using keystrokes to receive input from the user and I’m wondering how it actually behaves.
I would say that this is probably the system working as intended: if you’re looking at keystrokes, then there really are no “modified keys”–just whatever characters are being produced.
For example, pressing “Shift + c” doesn’t produce a “shift-c”, but rather a “C” (i.e. capital “c”). Hence that is the keystroke event produced.
And “Alt + c” doesn’t produce a distinct “keystroke”; if one were to create a giant keyboard with every possible key, such that every character and symbol had its own button, which one would correspond to the “Alt + c” “character”…?
Lacking such a character, I suppose that it just defaults to the base character.
That, at least, is my read on it.
(One might argue that it should send no event at all–but perhaps a lack of an event would be even more unexpected.)