I use the Dvorak layout. Attached to my desktop, I have a keyboard that internally outputs Dvorak, and macOS is set to Qwerty. On my laptop, macOS is set to Dvorak, since I'm using the internal keyboard.
This issue also applies to moving macros between other keyboard layouts, such as German, BÉPO, Italian, etc. So a German person's Cmd-Y becomes Cmd-Z to an American person, Cmd-W to a French person, and Cmd-; to a Dvorak user, Colemak, etc. Keystrokes generated by macros change in a similar fashion.
KM macro definitions are tied to the KeyCode of the physical keys on the keyboard, rather than the symbols they represent.
I propose that KM save it's macro definitions to its .plist file using definitions such as those in Carbon/Carbon.h, such as kVK_ANSI_Semicolon
rather than 41
, with the translation happening when loading and saving the .plist, and when the keyboard layout is changed in macOS.
E.g. rather than the current:
<key>KeyCode</key>
<integer>41</integer>
it might be:
<key>KeyCode</key>
<string>kVK_ANSI_Semicolon</string>
When the .plist file is read on my iMac Pro, any macro triggered by, or that generates kVK_ANSI_Semicolon
becomes 41
, and when read on my MacBook Pro, it becomes 6
.
What would this do?
Well, it would allow me to define a macro triggered by Cmd-; and have it work on both my iMac Pro using a Dvorak layout with macOS set to Qwerty, as well as my MacBook Pro with macOS set to Dvorak layout. On both machines, the macro would be triggered by the ;
key. It would also allow me to send a macro to a user with any other keyboard layout (that has a semicolon), and allow them to use it by pressing Cmd + their semicolon key, rather than mine (which as mentioned before would currently be Y for German, W for French, etc.).
I haven't written code for macOS, but the attached might be helpful.
There have been several posts about this over the years, and I'm sure it would be helpful to others besides me.