2

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.

  • Did you try the fn-F1 key chord? By default F1 is Dim Screen and fn-F1 is Function Key One. Personally, I prefer to use the Caps Lock key - I'll update my answer at https://Apple.StackExchange.com/questions/7231/how-can-i-rebind-caps-lock-to-delete-backspace – Devon Oct 13 '19 at 03:14
  • See also https://stackoverflow.com/questions/3202629/where-can-i-find-a-list-of-mac-virtual-key-codes/16125341 which recommends a utility called "Key Codes" from the Apple App Store at https://apps.apple.com/us/app/key-codes/id414568915?mt=12 – MarkHu May 25 '20 at 17:21

2 Answers2

1

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 ...

ernesto
  • 1,771
  • 2
  • 18
  • 18
  • The frustrating thing is that it the list of keys doesn't list them "all" and I can't find an app that detects them all. Trying to remap an odd bluetooth keyboard to be more standard. But if I don't know the number of the errant key I'm trying to remap, I can't script it. – MarkHu May 25 '20 at 18:10
  • 1
    Have you tried the EventViewer from Karabiner Elements? https://karabiner-elements.pqrs.org/ – ernesto May 26 '20 at 09:33
  • The `Karabiner-EventViewer` seemed exactly what I was looking for, and I had high hopes for it. But sadly, it showed nothing when I press the mystery key-that-should-be-ESC on my bluetooth keyboard. The app did accurately detect other keys like `type:consumer_key_down code:0xe9 name:volume_increment.` I've resigned myself to shopping for another keyboard that has a more traditional layout. – MarkHu May 26 '20 at 22:51
1

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.

Rémi
  • 11
  • 1