Logitech K860 right cmd/option swap position on Mac for better { } and [ ] type programming experience on ISO layouts.

When using this new keyboard I noticed the right command position forces to change my fingers combination using the pinky instead of the thumb to use the command key, switching to this new layout is a bit cumbersome when you are used to laptop keyboards which have this key left to the space bar.

The main problem for me is when typing [ , ] but mainly { , } which require to use SHIFT + COMMAND this makes you use a not so easy position or change to another fingers position which is not my preferred layout. The main culprit is the position of the FN button which i noticed has the same layout for MX Keys and MX Keys mini too (so is a common “mistake” for Mac ISO keyboard programmers) .

On MacOS you can swap the control keys but is for both of them and this means I will lose the left keycap which is not what I wanted.

How Logitech think you have to use it on Mac to type [ ] and specially { } vs other keyboards:

How Logitech suggest to swap fingers to use it

There are 2 solutions:

  1. Karabinier free application, which let to swap any keys (ref: https://karabiner-elements.pqrs.org) note: after swapping the keys using the “Simple modifications” area remember to enable “Modify events” in the “Devices” area.
  2. A simple plist inside the .LaunchAgents which swap them at reboot (provided as an attachment to this article which uses Product name and not ProductID, or you could follow the steps.)
How the two solutions “fixed” it;
Note: if the Mac layout its your only layout you could open it and swap physically the keys using the new remapping to match with the virtual one.


Way 2:

Create a file inside ~/Library/LaunchAgents/ called com.local.KeyRemapping.plist; (you can use any editor TextEdit too)

eg using vim: vim ~/Library/LaunchAgents/com.local.KeyRemapping.plist

Fill with the code (type i to enter edit mode) (created changing the version created here: https://hidutil-generator.netlify.app), save (type esc then wq! return to save and quit edit mote)


<?xml version=”1.0″ encoding=”UTF-8″?>

<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN” “http://www.apple.com/DTDs/PropertyList-1.0.dtd”>

<plist version=”1.0″>

<dict>

    <key>Label</key>

    <string>com.local.KeyRemapping</string>

    <key>ProgramArguments</key>

    <array>

        <string>/usr/bin/hidutil</string>

        <string>property</string>

        <string>–matching</string>

        <string>{“Product:”ERGO K860”}</string>

        <string>–set</string>

        <string>{“UserKeyMapping”:[

            {

              “HIDKeyboardModifierMappingSrc”: 0x7000000E6,

              “HIDKeyboardModifierMappingDst”: 0x7000000E7

            },

            {

              “HIDKeyboardModifierMappingSrc”: 0x7000000E7,

              “HIDKeyboardModifierMappingDst”: 0x7000000E6

            }

        ]}</string>

    </array>

    <key>RunAtLoad</key>

    <true/>

</dict>

</plist>

Then: launchctl load ~/Library/LaunchAgents/com.local.KeyRemapping.plist

No output? All goes well,

Error 5? try launchctl unload ~/Library/LaunchAgents/com.local.KeyRemapping.plist and load again

Now: launchctl list | grep local

You should find a row with the plist Label:

35903 0 com.apple.localizationswitcherd
0 com.local.KeyRemapping

Then: launchctl start local.KeyMapping

All good? No output from the command

Finally: hidutil property --get "UserKeyMapping"

You should see :

(
{
HIDKeyboardModifierMappingDst = 30064771303;
HIDKeyboardModifierMappingSrc = 30064771302;
},
{
HIDKeyboardModifierMappingDst = 30064771302;
HIDKeyboardModifierMappingSrc = 30064771303;
}
)

Note: if not working: you can try replacing {"Product:"ERGO K860"} with {"ProductID:"0xhexcode"} where "hexcode” with the Product ID (in my case was 0xB359) found in the Apple Menu -> System informations area

Tip to revert back :

hidutil property --set '{"UserKeyMapping":[]}'

launchctl stop ~/Library/LaunchAgents/com.local.KeyRemapping.plist

The command could be delivered simply by the terminal inline: hidutil property –matching ‘{“ProductID”:0xB359}’ –set ‘{“UserKeyMapping”:[{“HIDKeyboardModifierMappingSrc”: 0x7000000E6,”HIDKeyboardModifierMappingDst”: 0x7000000E7},{“HIDKeyboardModifierMappingSrc”: 0x7000000E7,”HIDKeyboardModifierMappingDst”: 0x7000000E6}]}’