Key remapping built into macOS

Ryan Hanson
Ryan Hanson
Published in
3 min readApr 13, 2023

--

If you want to simply remap one key to another key in macOS, there’s no need for third party tools. The most common reason to do this is to use a windows keyboard with your Mac. Here’s a quick guide for it:

If you only want to remap modifier keys, you can use System Settings. Search for “customize modifier keys”.

Beyond that, macOS has a way to remap keys using a built-in tool called hidutil:

Probably the quickest way to utilize hidutil is to use this generator and copy/paste the output as directed:

https://hidutil-generator.netlify.app/

Maybe you want a little more control over what’s going on, though. Let’s run through creating a simple Automator app that invokes the command line hidutil, and turn it into something we can set up to run when we want.

As an example, let’s remap the menu button (depicted by three horizontal lines) on a Windows keyboard to the right command key.

1. Open Automator

2. Create a new Application

3. Drag and Drop “Run Shell Script”

4. Paste in the following. Note that these values were obtained in the Apple Tech note referenced above:

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

5. Export the app in automator. If you have a developer id, you can sign it here to pass it around to other macs.

6. Now that you have an app, you can add it to your login items in System Settings, just search “login items”, and add it there.

You can use those same steps to create another app for clearing your remapping, if desired. Here’s the terminal command for clearing the remapping :

hidutil property --set '{"UserKeyMapping":[]}'

If you want more complicated key remapping, you’ll need a third party app. Here are some options made by me.

  1. Multitouch is a paid app that lets you add more gestures to macOS, and remap keys to do whatever you want. It also comes with my window management app, Rectangle, built-in.
  2. Hyperkey is a free app that has one job — remapping a key to the hyper key (⌃⌥⌘⇧). The hyper key can be used as an extra modifier key that won’t conflict with other keyboard shortcuts.
  3. Superkey is a paid superset of Hyperkey that has more key remapping capabilities. It also includes a feature called Seek that will find matches for what you type and click it. Avoid having to reach for a pointing device!

--

--