There is an eject key on the upper right corner of my Magic Keyboard. Since I'm neither using the eject key directly nor any of the shortcuts associated to it, I would like to remap it to a symbol that I use more often. That is in my case the backslash.

How can I remap the eject key to backslash, preferably without using third-party software? I'm using High Sierra version 10.13.3 on a Macbook Pro 2017.


Scripting Key Remapping

Keys can be remapped via the command-line tool hidutil. For example, use the hidutil command-line tool to remap the 'A' key to the 'B' key as shown in Listing 1. The map array consists of two key/value pairs that contain the source (HIDKeyboardModifierMappingSrc) and destination (HIDKeyboardModifierMappingDstKey) of the key remapping. The keys take a hexadecimal value that consists of 0x700000000 or’d with the desired keyboard usage value (see Table 1 for usage values).

Listing 1: Remapping keys in a script Use The value From the Table Given In the Link

$ hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000004,"HIDKeyboardModifierMappingDst":0x700000005},{"HIDKeyboardModifierMappingSrc":0x700000005,"HIDKeyboardModifierMappingDst":0x700000004}]}'

A null result indicates that there are no key remappings active.

Listing 2: Checking Key Remapping state

$ hidutil property --get "UserKeyMapping"


  • Is this persistent across reboots? – Allan Apr 23 '18 at 13:53
  • 1
    This still doesn't answer OP's question. The linked document doesn't contain keycode for key. – Nimesh Neema Apr 23 '18 at 13:55
  • github.com/tekezo/Karabiner-Elements external Library It Has eject key mapping one can copy or use . – Amey Apr 23 '18 at 13:59

Not the answer you're looking for? Browse other questions tagged .