Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Oneechan69

macrumors 6502
Original poster
Mar 29, 2022
285
34
US
hidutil seems much more complicated to use as a CLI or with scripts or config files (however you do it) compare to using apps that make the process much easier.
 
Be careful with Karabiner.

Once installed, it's complicated to remove (if it does nothing for you)...
 
  • Like
Reactions: MBAir2010
I run the following script as a LaunchAgent, so it gets applied automatically when I log in. Works fine and I haven't had to think about it for a long time, so I would say a benefit is that it's rock solid.

Code:
#!/usr/bin/env bash

# REF: https://developer.apple.com/library/archive/technotes/tn2450/_index.html

# Remap:
#   RightCmd  -> F17
#   CapsLock  -> F16
#   RightCtrl -> F15
hidutil property --set '
{
    "UserKeyMapping": [
        {
            "HIDKeyboardModifierMappingSrc":0x7000000e7,
            "HIDKeyboardModifierMappingDst":0x70000006c
        },
        {
            "HIDKeyboardModifierMappingSrc":0x700000039,
            "HIDKeyboardModifierMappingDst":0x70000006b
        },
        {
            "HIDKeyboardModifierMappingSrc":0x7000000e4,
            "HIDKeyboardModifierMappingDst":0x70000006a
        }
    ]
}' >/dev/null

Using hidutil like this is about very simple 1:1 key remappings though. It has nothing to say about specific key combinations including modifier keys etc.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.