I would like to switch the Right Command (⌘) Key order with the Alt Key under the System Preferences (to be just like Windows) but there appears to be no option under System Preferences.

Does anyone know how to move these keys' locations using Karabiner-Elements or some other software? In this case we would swap the right-hand Alt and Command keys.

Modifier Keys in System Preferences
(source: tekrevue.com)


3 Answers 3


Apple's Technical Note TN2450 describes how to remap keys. It is important to know that Right Command is also Right GUI. Running the following command will switch Right Command and Right Alt (if you also want to do the Left Command and Left Alt, refer to the technical note to get the hex values and the Python code below to do the or operation).

hidutil property --set '{"UserKeyMapping":

The table at the bottom of the Technical Note has a list of hex values for each key. To generalize the above answer to switch any keys (at least is macOS Sierra), you must or the hex value from that list together with 0x700000000. The following Python code demonstrates one way to do this.

In [1]: def convert(val):
   ...:     int_val = int(val, 16)
   ...:     ref = '0x700000000'
   ...:     int_ref = int(ref, 16)
   ...:     return hex(int_ref | int_val)

In [2]: r_alt = '0xE6'

In [3]: print(convert(r_alt))
  • Works for Mojave as well.
    – itachi
    Commented Aug 19, 2019 at 15:05
  • 1
    Works on Catalina as well. And is better than Karabiner-Elements as it does not interfere with Logitech Options - that I use for an external keyboard. Unfortunately, this setting disappears after shutdown. @steven-c-howell do you have any solution for that?
    – Pawel
    Commented May 6, 2020 at 12:24
  • 1
    @Pawel you could try to setup an automator app like here: superuser.com/a/465506/1415759
    – Appyx
    Commented Jun 10, 2021 at 7:39
  • Remember that this only works if you haven't used the "modifier keys" option in the macOS settings to switch keys (control, option, command, ...).
    – mhellmeier
    Commented Aug 26, 2021 at 18:35

A more general and user-friendly approach is to use Karabiner-Elements, which is a version of Karabiner that works on Sierra.

Karabiner-Elements allows for your specific use case (that's how I use it) in addition to almost any other kind of key remapping.

My configuration looks likeenter image description here

  • I'm currently using Karabiner Elements to map right command key to right option (alt) key. I suggest you download and test - maybe the author just hasn't updated your issue (there are over 400 issues logged).
    – mikaraento
    Commented May 20, 2017 at 18:36
  • 1
    Could you post your configuration then? That is what I stated in the question.
    – William
    Commented May 20, 2017 at 18:49
  • Here you go, I added an image to the answer.
    – mikaraento
    Commented May 22, 2017 at 20:34

Do you want to swap Option (Alt) with Command or Control with Command?

See Changing modifier keys from the command line

  • 1
    Right Command and Right Alt should be swapped
    – William
    Commented Apr 20, 2017 at 0:14

You must log in to answer this question.

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