Different key mappings on Multiple Keyboards?

Hi gang,

I don't (yet) have Keyboard Maestro; I'm wondering if it'll do what I need:

I have two keyboards on my iMac (Big Sur). Both are bluetooth; one is from Apple, the other's an oddball "Xiwmix" keyboard. Both work fine, and I can type on either.

I'd like the Apple keyboard to work completely normally. But I wish to remap several keys on the. For example, I'd like the Xiwmix "A" key should trigger an AppleScript named "abracadabra". The "B" key should start AppleScript "BovineBox". etc

So: Can Keyboard Maestro remap one keyboard's keystrokes, without disturbing the keys of the other keyboard? If so, I'd certainly appreciate any pointers to get started.

In advance, MANY THANKS!
-Cliff (a sunny Tuesday morning in Oakland, California)

@peternlewis?

As far as I know, we can't do it natively with Keyboard Maestro. If we use keypress as trigger, Keyboard Maestro does not distinguish the same key on different keyboards.
If we use USB keys, Keyboard Maestro does not swallow the key output. And pressing A will output A.

The only way I can think of is to remap your other keyboard with Karabiner-Elements to the keys that will not have any outputs, for instance, remapping A to + F1. Then you can use keypress trigger with Keyboard Maestro.

No. See: Frequently Asked Questions “Can I use a second keyboard solely to trigger macros?”

You cannot really do this with Keyboard Maestro.

Keyboard Maestro has two primary key triggers: hot keys and device keys.

Hot keys intercept and swallow the key press but cannot distinguish between the same key on different keyboards.

Device Keys can distinguish the key on different keyboards, but do not swallow the key so the key continues to perform its normal function.

So you could use all the function keys (with associated modifiers) on both Macs using a device key trigger. But you could not use, for example, the “a” key on a second keyboard without also typing an “a” (or swallowing both a's if you used a hot key).

An alternative is to use a non-keyboard keyboard, something like an XK-24 or the like, that does not perform any normal function. You can use device key triggers with that kind of keyboard.

Also, with version 9, Keyboard Maestro adds direct support for the Stream Deck, including the ability to trigger macros as well as control the image and title of the buttons.

Welcome @CliffStoll,
as Martin mentions, your best bet is Karabiner. With it you can remap keys of one keyboard without disturbing other keyboards.
If you have any questions let us know.

Example of remapped key script to run a Keyboard Maestro macro:

1 Like

You can absolutely do this on KM. I have a separate keyboard on a stand with stickers on the key caps for precisely this purpose. Here’s my description: Link

Happy to answer any questions…

Kind regards, keep safe...

Jonathan

Hi @c15jon,

I took a look at your triggers. It does work, but it suffers from this:

This is exactly why your have to simulate a Delete keypress. The Karabiner-Elements approach can avoid this issue.

As @hello has pointed out, you may also trigger macros by running shell script (to event definition | Karabiner-Elements) set in Karabiner-Elements. You can add the device_if, device_unless | Karabiner-Elements condition to make the triggers exclusive to a specific keyboard.

2 Likes

Hi @Martin - hope you're well. I can't disagree that you have to send the delete keypress first but (at least for my workflow) this doesn't cause an issue. I use KM with the external keyboard exclusively for sending text commands to remote VMs I'm connected to over ssh (using the awesome Core Shell). I do this by having a bunch of named clipboards with each command defined in the Preferences. So a typical sequence is: Send delete > Copy system clipboard to a temp scratchpad clipboard>Paste the correct named clipboard>copy the temp scratchpad back to the system clipboard so it is not corrupted by the operation.
It works for me...
Keep safe...

1 Like

I agree. I can imagine that it should work well in most cases, more so if you limit it to certain use cases.
The benefit is that we can avoid using Karabiner-Elements.

My concern was that the Delete key might accidentally delete something that cannot be recovered. I just had one a few days ago:

Also, Karabiner-Elements offers more options:

image

I'm not against your implementation at all. I think it is a very creative way to handle the USB keypress issue. I have not thought of this solution before! I appreciate your sharing your solution! Karabiner-Elements, on the other hand, is probably for those who are comfortable with JSON file and want more capabilities with a single key.

1 Like

Thanks, @Martin - I will look into Karabiner, I had not heard of it before and it might be useful.
I'm wondering if you could use named clipboards instead of variables? Perhaps even backing them up before changing them?
Something like (assume I want to save page_count under macro control):
copy page_count value to system clipboard>copy page_count named clipboard to page_count_backup named clipboard>copy system clipboard to page_count named clipboard.
The idea being you have the value in a clipboard for relatively secure storage, and you take a backup every time you change it...
Keep safe...

Thanks for the suggestion. Variables are usually preferred over clipboards for plain texts. @ccstone has provided a macro to back up all variables, so it's not a big issue now. (I think we may also simply backup the variable file instead). My point was that simulating the delete key could cause unexpected results that might not be recoverable.

1 Like