zenangst / KeyboardCowboy

:keyboard: The missing keyboard shortcut utility for macOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Language agnostic keyboard shortcuts

amatoenot opened this issue · comments

It would be nice to have language-agnostic keyboard shortcuts. It seems all other system shortcuts work with key codes instead of actual symbols, so the input source doesn't matter, which is not the case with the Keyboard Cowboy. Currently, as a workaround, I have to duplicate actions to have shortcuts working in both languages.
image

Hey @amatoenot, unsure how you would make this agnostic as the underlying key codes sent by the keys varies depending on which layout you are using.

Could you elaborate how this would work in practice?

Hi @zenangst,
Not sure exactly. Afaik keyboard key HID is the same for any language. So maybe it's possible to create shortcuts mapped to the key HID somehow. Most of the default mac os shortcuts work this way (e.g. 'CMD + C key' copies in any language)

I haven't found any information about HID related information on CGEvent's (which we are using to identify events).

https://developer.apple.com/documentation/coregraphics/cgeventfield

What about CGEventField.keyboardEventKeycode? Sounds like something that can be used to identify key instead of a character.

https://developer.apple.com/documentation/coregraphics/cgeventfield/keyboardeventkeycode

That is what is used to identify it today, but the current input source send different key codes for different keys depending on the layout.

For users with multiple language keyboard layouts it's a pain to manage.
I'm using 3 languages and it hard to keep working with 30+ shortcuts.
All keyboard shortcuts managers that I used over decades is language-agnostic.
Maybe Karabiner-Elements source code will be helpful?

@ww7 that's a good idea. I'll check it out when life allows.

I looked into the source code of Karabiner-Elements and they use a kernel extension which is a completely different integration level than Keyboard Cowboy.

But I'll continue to investigate to see if this can be done with the current mach port implementation.

Maybe such old project can help? (sorry, I'm don't have any experience on macOS programming)
https://github.com/shortcutrecorder/shortcutrecorder

Took a quick glance at [shortcutrecorder](https://github.com/shortcutrecorder/shortcutrecorder). Seems like that also is dependent on the current layout of the keyboard when mapping.

Note that I didn't do a deep-dive.