Re-mapping tilde ~ to escape with hidutil, hex code is wrong on technical note

keybindingskeyboardterminal

I want to map my esc key to ~ tilde.

Using this reference: How do I remap a key in macOS Sierra, e.g., Right Alt to Right Control?

I found this technical note

Using this code:

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

The problem is the escape key outputs \| and not ~. I thought that maybe a typo resulted in the codes being swiched. so I also tried 0x31, 0x32, 0x33, 0x34, 0x35.

BOTH 0x32 and 0x31 result in \| back slash char… Does anyone know the correct code to use for the tilde ~ key, that one you use to go to the home dir. Thanks

Edit: langue is US English, Mac OS 10.14,

Best Answer

So i thought I tried 35, but i guess i missed it.

The `~ key is 35.

So just to be clear this [technical note] Has everything correct however i was confused by the non-Us keyboard vs graveaccent/Tilde names.

~ key is 35

\| key is 31 and 32 (for us keyboards)