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, 2017 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, 2017 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, 2017 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, 2017 at 7:40
  • @JosephH Did you manage to confirm whether or not your original idea above actually works? It would be good to have that as another answer. Nov 13, 2020 at 18:26

4 Answers 4

  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)

  • 1
    typo: s/non-us-backlash/non-us-backslash Oct 18, 2018 at 12:18

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">
  • 1
    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, 2018 at 14:22
  • How do I keep access to shift-§ so I can still use ±? I.e. can I use modifiers?
    – Wivku
    Jul 2, 2019 at 18:58

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.


If you're using macOS 11, things have changed: Big Sur has breaking changes for "Karabiner", as macOS 11 "will no longer load kernel extensions that use deprecated Kernel programming interfaces (KPIs) by default" (As stated on Karabiner's website, developers are working to migrate to a newer mechanism, DriverKit, from kernel extension and they plan to support it at Karabiner-Elements 13.0.0).

If you're here to remap escape, perhaps to section you could use: Remap Keyboard. Version: 1.6 is: "Try for free and remap any one key."

Although, my hope is in future is Apple extends remapping the keyboard beyond just the modifier keys.

You must log in to answer this question.

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