The UK keyboard layouts for the TouchBar MacBook Pro's have a pretty useless §/± key at the top left that would be a perfect to use as a physical escape key (see this image).

macOS has a keyboard mapping system (/Library/Keyboard Layouts/ - eg. see http://www.gingerbeardman.com/UK.keylayout/ and https://developer.apple.com/library/content/technotes/tn2056/_index.html ) that allows keys to be changed around.

It seems possible to me that putting a line into the relevant keyboard layout similar to:

<key code="<code for that key>" output="&#x1B;" />

should allow me to make that key an escape key. (If I can find/create the layout for all the other keys too!)

Googling I've not found anyone mentioning they've done this, which seems odd to me. Is there some reason this wouldn't work? Can the TouchBar keyboard be remapped with a .keylayout file without losing any functionality?

I've been holding off buying a new macbook pro because of fear of losing the physical escape key! I know you can remap ctrl/cmd/etc to be Escape using System Preferences, but that seems like a poor solution in comparison.

  • What key are you going to use if not caps lock or the included ones Apple makes very easy and configurable? – bmike Apr 27 '17 at 20:38
  • 1
    @bmike The §/± key at the top left of the UK keyboard layout - see this image to see the key I'm talking about: d.ibtimes.co.uk/en/full/1570365/macbook-pro-touch-bar.jpg - it's a useless key that I've never used for it's intended purpose on any mac! – JosephH Apr 28 '17 at 9:35
  • Wow - I missed that part entirely. Let's see if I can find any options to remap that. My answer isn't that flexible with the "easy" remap option. – bmike Apr 30 '17 at 2:39
  • @bmike Thanks! Yeah. It's an interesting option not really available on US keyboard maps. :-) I hope it's achievable with a .keylayout. I've actually ordered the MacBook Pro Touchbar now so will be able to experiment when it arrives. – JosephH Apr 30 '17 at 7:40
up vote 8 down vote accepted
  1. Install Karabiner-Elements
  2. Run it form the Launchpad (obviously)
  3. In "Simple Modifications" tab create a mapping "non-us-backlash" to "escape"
  4. Enjoy!

BTW key code for "§" is 0A (as reported by Karabiner Event Viewer)

  • typo: s/non-us-backlash/non-us-backslash – Shlomi Noach Oct 18 at 12:18

Open System Preferences - select keyboard. Then select Modifier Keys... towards the bottom right of the window.

I have escape assigned to the caps lock key.

enter image description here

I agree using the control keys for escape is poor, but the caps lock key works very well. In practice, I've not really had any issue learning to use the soft escape key. Having caps lock is far faster once I got used to it due to decreased travel distance from the home row.

I found some documentation on Remapping Keys in macOS 10.12 Sierra that works without any third party tools.

To change the key just above tab, set src to 0x64 (Keyboard Non-US \ and |) and dst to 0x29 (Escape). These values should be OR'd with 0x700000000 in the call to hidutil for some reason.

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

You could put this in a LaunchAgent (~/Library/LaunchAgents/give.me.esc.key.plist) to have it set every time you log in.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>give.me.esc.key</string>
    <key>ProgramArguments</key>
    <array>
        <string>hidutil</string>
        <string>property</string>
        <string>--set</string>
        <string>{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000029}]}</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>
  • You saved my life. I hate keyboards with tilda key next to short shift button and f*n § button under escape. So I remapped it with tilda button and extended shift. hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000064,"HIDKeyboardModifierMappingDst":0x700000035},{"HIDKeyboardModifierMappingSrc":0x700000035,"HIDKeyboardModifierMappingDst":0x7000000e1}]}' By the way you can get those codes using key viewer from karabiner – DanSkeel Jul 16 at 14:22

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.