In case you don’t get it working with KM, another option to consider is another low-level utility called ControllerMate by OrderedBytes. It is completely compatible with Sierra and has a great graphical interface for configuration/remapping almost any input controller (much nicer [1] than Karabiner’s complicated XML syntax). I’ve been using CM for many years and highly recommend it. Look over the main product page to get an idea but also check out the Examples page for just a small sample of what is possible with CM.
CM is free to try out and might even stay free for you (at least for a while). It is limited to 10 building blocks that send output. For what you need, you would only need 2 (to output control and command depending on the input and the active app)
I use CM to do similar remaps to what you are wanting. For example, when I’m using VMware Fusion to run a Windows VM …
- CM remaps the left Command key to the Windows Key but keeps the right Command key as an OSX Command key.
- Control+\ is already used for a KM shortcut so I have CM allow the left Control+\ run the KM shortcut but intercepts the right Control+\ to do a different macro appropriate for the Windows VM.
- CM disables the main keyboard driver map and enables a custom keyboard map where certain F-Keys are sent through as normal F-Keys for Windows functions (edit, refresh, etc) but the other F-Keys are kept as OSX “media” keys (Play/Pause, Volume, etc).
- For the Windows F-Keys that would normally do OSX functions, I have an advanced set of CM blocks to do the OSX function when the key is held down for more than 1 second.
- CM immediately switches the keyboard mapping as soon as I switch out of the Fusion app.
When using a multi-button mouse instead of a Magic Trackpad, I have CM configured to remap the additional buttons to do many different functions based on which application is front-most.
Just recently I was given an old DJ mixer controller which connects via USB and is seen as a MIDI instrument. Using CM, it can react to every button, knob, and slider on the mixer, including sending back MIDI commands to turn the button lights on and off. It is very fun.
This is just a very small sample of how I use CM, and I know it can do a lot more. (Just like Keyboard Maestro. I think I have maybe a dozen KM macros and I’m sure others like Peter and JMichael probably use hundreds every day)
I hope this helps. Let me know if you try CM and run into problems (although we might have to take it over to the CM forums)
[1] Please don’t get me wrong in that I don’t like Karabiner. In fact, before Sierra, I loved it and used it to do many functions. It, along with the companion app Seil, were the only apps (I thought) capable of doing what I needed. Since then, I’ve ported all those functions over to KM and CM (and BetterTouchTool). As Karabiner Elements develops, I check on it but it has yet to even come close to what can be done with KM/CM/BTT.