Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kVK_ANSI_ virtual keycodes don't match output in Dvorak or non-QWERTY international keyboard layouts #2

Open
pkamb opened this issue Jul 22, 2017 · 4 comments

Comments

@pkamb
Copy link

pkamb commented Jul 22, 2017

Cool and useful framework! This is just a heads up, not a request for an immediate fix or anything, about an issue I have some experience with having written some keyboard apps and being a Dvorak typist.

The kVK_ANSI_A virtual keycodes reference physical key locations on a standard QWERTY hardware keyboard. If the typist is using a different software keyboard layout, the key codes will no longer match the output letter specified in the name.

So tables like:

case .o: return UInt32(kVK_ANSI_O)
...
case UInt32(kVK_ANSI_O): self = .o

will only work for typists using a U.S. QWERTY keyboard.

Those constants with "ANSI" in the name are labeled according to the key position on an ANSI-standard US keyboard. For example, kVK_ANSI_A indicates the virtual keycode for the key with the letter 'A' in the US keyboard layout. Other keyboard layouts may have the 'A' key label on a different physical key; in this case, pressing 'A' will generate a different virtual keycode.

I wrote a bit about this on the Stack Overflow question here:

https://stackoverflow.com/questions/3202629/where-can-i-find-a-list-of-mac-virtual-key-codes/16125341#16125341

Some strategies for layout-agnostic conversion of keycodes to output are here:

https://stackoverflow.com/questions/1918841/how-to-convert-ascii-character-to-cgkeycode

@pkamb pkamb changed the title kVK_ANSI_ virtual keycodes don't match output in Dvorak or non-QWERTY international keyboard layouts kVK_ANSI_ virtual keycodes don't match output in Dvorak or non-QWERTY international keyboard layouts Jul 22, 2017
@rgbworld
Copy link

rgbworld commented Nov 8, 2017

I am developing a macOS desktop app that is localized in several languages. Is this issue going to affect all non-US users if I were to use HotKey?

@soffes
Copy link
Owner

soffes commented Nov 22, 2017

@pkamb good call. I had no idea. I'll try to implement this when I have time.

@rgbworld I'd wager non-US keyboards would have trouble with this.

@rampatra
Copy link

rampatra commented May 2, 2020

Curious to know whether any work was done on this?

I used HotKey and a user using Swiss-French keyboard complained about shortcut keys not working. Upon some investigation(by changing my keyboard layout in System Preferences, etc.), I figured that this is the issue.

@soffes
Copy link
Owner

soffes commented May 7, 2020

Realistically, I'm not going to have time to work on adding this feature any time soon :/

If you want to PR something, I'd be happy to take a look though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants