You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

`hidutil` stopped working on macOS 14.2

I've got the following command to run on every macOS start:


hidutil property --set '{"UserKeyMapping": [{"HIDKeyboardModifierMappingSrc": 0x700000064, "HIDKeyboardModifierMappingDst": 0x700000035}]}'


It always rebinds a key on my international Apple Magic Keyboard to a convenient one to match with my us keyboard laptop.


Right after 14.2 install this command stopped working. It throws no error, the


hidutil property --get UserKeyMapping


prints out some kind a valid output as follow, but the key behaviour isn't updates after the command run as it appears before update. Also I'm not sure that in the past the --get argument output was printed out as a Decimal rather than hex. But this is as it is now.


The command output:


(
        {
        HIDKeyboardModifierMappingDst = 30064771125;
        HIDKeyboardModifierMappingSrc = 30064771172;
    }
)

MacBook Pro (M1, 2020)

Posted on Dec 12, 2023 4:21 AM

Reply
Question marked as Top-ranking reply

Posted on Dec 18, 2023 1:33 AM

UserKeyMapping with hidutil is no longer working for me after upgrading to 14.2. I'm on a restrict macOS where it's not allowed to install third-party software.


I need to map these keys § <=>`, and ± <=> ~ which swap some special keys from Norwegian keyboard layout to US keyboard layout. Even I did change the layout to US in Keyboard settings but it didn't help for those keys. hidutil was really helpful to map them. Now, it's gone. This impacts my daily work's speed.


UserKeyMapping:(
        {
        HIDKeyboardModifierMappingDst = 30064771172;
        HIDKeyboardModifierMappingSrc = 30064771125;
    },
        {
        HIDKeyboardModifierMappingDst = 30064771125;
        HIDKeyboardModifierMappingSrc = 30064771172;
    }
)
50 replies

Jan 15, 2024 11:32 PM in response to yaroslav280

Hello, I encounted the same problem, but I solved it successfully using hidutil.

STEPS:

  1. remove the usb of keyboard on the mac
  2. restart the computer
  3. the hidutil does not work right now
  4. plug the usb of our keyboard, then the hidutil will write the config to macos immediately in 1 second.

I think that hidutil bonded with certain device(my keyboard), so when I plug usb in, hidutil writed the config to computer. But if I donot plug the usb in(or donot remove the usb when I restart computer), the write event do not happen, looks like that macos do not allow modify the keyboard on macbook, but allow modify the keyboard third-party

Dec 13, 2023 7:52 AM in response to Tom Gewecke

Hi Tom,


I have the same need for swapping the `Keyboard Delete Forward, 0x4C` with `Keyboard \ and |, 0x31` and then swapping `Keyboard \ and |, 0x31` to the `Keyboard Right Alt, 0xE6`. I used to do it with this command until 14.2 as well.

```

hidutil property --set '{"UserKeyMapping":

  [{"HIDKeyboardModifierMappingSrc":0x700000031,

   "HIDKeyboardModifierMappingDst":0x70000004c},

   {"HIDKeyboardModifierMappingSrc":0x7000000e6,

   "HIDKeyboardModifierMappingDst":0x700000031}]

}'

```

I'm on a work laptop that restricts apps so I cannot download karabiner, so do you please mind sharing/showing me how to create a custom layout with these swaps as well? I'd very much appreciate it.


Thanks!



Dec 27, 2023 7:37 AM in response to Tom Gewecke

The thing is that the layout from the "Others" section is not considered as an ABC (non-removable). So looks like I have one more language because the ABC can not be replaced with this one. Also, the Caps-lock language switch does not work as expected.

Don't you know if I can change existing layouts from "English" section or move your custom layout to "English" section?

Dec 27, 2023 8:11 AM in response to mikeldpl

mikeldpl wrote:


Don't you know if I can change existing layouts from "English" section or move your custom layout to "English" section?

This version should go into the English section, but I don't think you can have a custom layout as the only latin keyboard item on your input sources list. This one should also do the caps lock thing with non-Latin keyboards. It is a .bundle file instead of .keylayout, which has more options.

Jan 2, 2024 2:32 AM in response to Tom Gewecke

How can I do this for other keys? I am having a similar issue, as I use a German keyboard (QWERTZ) and used the hidutil command to swap the Z and Y keys:


hidutil property --set '{"UserKeyMapping":[
{"HIDKeyboardModifierMappingSrc":0x70000001D,
"HIDKeyboardModifierMappingDst":0x70000001C},
{"HIDKeyboardModifierMappingSrc":0x70000001C,
"HIDKeyboardModifierMappingDst":0x70000001D}
]}'


Thanks!

Jan 2, 2024 4:31 AM in response to Tom Gewecke

Thank you for that solution! It worked for me as well

The only drawback is that MacOS won't let you remove the ABC (default) keyboard in exchange with this one. So if someone who already has 2 keyboard layouts like me wants to add your layout it needs to be the third keyboard layout which becomes a nuisance (switching between 3+ layouts)

Apr 3, 2024 9:49 PM in response to yaroslav280

Hidutil now needs sudo permissions:

sudo hidutil property --set '{"UserKeyMapping": [{"HIDKeyboardModifierMappingSrc": 0x700000064, "HIDKeyboardModifierMappingDst": 0x700000035}]}'


If you use a launch agent plist file, then add this line:

<string>sudo</string>

above

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



To remove touchid/password on execution of hidutil with sudo privileges, you need to create a file and open it with this command and location:

sudo $EDITOR /etc/sudoers.d/hidutil

Paste in it the result of this command:

echo "$(whoami) ALL=(root) NOPASSWD: sha256:$(shasum -a 256 $(which hidutil) | cut -d " " -f 1) $(which hidutil)"

Save it.

`hidutil` stopped working on macOS 14.2

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.