Nathan Diehl
Nathan Diehl

Reputation: 43

Key-remapping using Macbook command-line

The "delete" key on my Macbook is broken. I am attempting to use the hidutil command to remap F1 as my new delete key. The command isn't performing as expected.

The command requires the hex ID's for the keys whose values I'd like to interchange. I've located a resource that provides these hex ID's as well as an overview of how to perform the remapping (https://developer.apple.com/library/archive/technotes/tn2450/_index.html).

I've posted my specific code below. It adheres to the suggested format, but my OS doesn't seem to register any change. Can someone help me identify the issue? I suspect my Hex ID's are wrong, but it may very well be another issue.

Input :

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

Output :

UserKeyMapping:(
    {
    HIDKeyboardModifierMappingDst = 58;
    HIDKeyboardModifierMappingSrc = 42;
    },
    {
    HIDKeyboardModifierMappingDst = 42;
    HIDKeyboardModifierMappingSrc = 58;
    })

There are no error objects. And judging by the output after the command is run some key remapping has occurred. However, my F1 key still retains functionality as F1 and doesn't delete I'd expected.

Upvotes: 2

Views: 2011

Answers (2)

Rémi
Rémi

Reputation: 11

Thanks for the above information, I was able to remap the right Ctrl key to be the Command key on the mac with the following command.

% hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x7000000e4,"HIDKeyboardModifierMappingDst":0x7000000e3}]}'

This is because I am using a very old IBM original keyboard that does not have a windows key, just an empty space between the Ctrl and Alt keys on the left and right of the Space bar.

Upvotes: 1

ernesto
ernesto

Reputation: 1818

Your referenced link on apple.com says "The keys take a hexadecimal value that consists of 0x700000000 or’d with the desired keyboard usage value." So I think you should try e. g. HIDKeyboardModifierMappingSrc":0x70000002a ...

Upvotes: 1

Related Questions