27

I'm used to having the Control button at the bottom left corner of the keyboard. It's a little annoying to be pressing Fn + Tab when I wanted a Control + Tab and the position of the Control button in the new Mac keyboard layout is just very uncomfortable for any finger to reach.

Does anybody know how you can make the Control and Fn buttons change function like how you can change the modifier keys in System Preferences?

Thecafremo
  • 13,617
  • 3
  • 45
  • 48
radj
  • 736
  • 12
    Does anyone know why on earth has Apple decided to do this? – Mahdi Mar 30 '17 at 08:06
  • Is it possible to map fn key only for combinations of alphanumeric keys? I would like fn key behave like control key only when pressed with combinations fn+a, fn+b..., fn+z, fn+1...fn+0. I would like still to get fn+F1, fn+F2... to work as factory default. – Marecky Dec 14 '21 at 13:29
  • @Mahdi would like to know that as well. Worst part is their larger num pad keyboard has a big ctrl button and the fn key is somewhere else entirely. Consistency at its finest. – Martin Braun Aug 13 '23 at 17:38

10 Answers10

22
  1. Download and install Karabiner

  2. Open Karabiner Elements and set the Target Device in the dropdown

  3. Map fn to left_control and left_control to fn as below

    Karabiner Elements Map fn to control

grg
  • 201,078
WiredIn
  • 320
19

Not sure which OS this started appearing in but in macOS 10.13, this can be customized in System Preferences > Keyboard > Modifier Keys:

System Preferences > Keyboard > Modifier Keys

radj
  • 736
  • 15
    I'm running 10.13.3 but do not see the fn Key in the modifier key window. Was it removed again? – Spork Mar 27 '18 at 15:26
  • @Spork I am also on 10.13.3 right now and I can still see the fn key modifiers. – radj Apr 04 '18 at 03:50
  • 7
    That's peculiar. I double checked, but see only 4 options. It also doesn't show up on google images for 'modifier keys' (the only exception being the image in this answer). Are you sure it isn't something you've installed? – Spork Apr 04 '18 at 07:43
  • 19
    Sadly this only works to map fn to ctrl but it's impossible to map ctrl to fn. – andresp Jul 02 '18 at 13:21
  • do you know if this works for a laptop keyboard or just external one? – William Aug 24 '18 at 23:55
  • @William in my setup, it works for both. – radj Aug 27 '18 at 04:41
  • 2
    I'm in 10.14.2 and also only seeing 4 options (fn not being one of them). – rept Jan 07 '19 at 23:49
  • I can confirm the issue that others are mentioning in the comments (in Mojave, 10.14.2), strangely enough no key except the real fn key can be mapped to fn; you can map fn to command but not command to fn. I guess this is okay for me since I rarely use fn. – jrh Jan 13 '19 at 02:26
  • 1
    This, plus binding Caps Lock › Esc, is an absolute gamechanger for Vim – iono Jul 11 '19 at 06:33
  • 3
    Apple doing it again, can remap fn to ctrl but not the otherway around, truly geniuses ahead of its time. – Ivan Castellanos Nov 24 '19 at 01:40
  • On my macbook pro keyboard (QWERTY) I have 4 options. On my iMac's external Apple keyboard with numpad (AZERTY) I have the above 5 options. Both systems run macOS 10.15.5. Not sure if it's external vs laptop keyboard, or related to the keyboard layout/language. If it's the former, it would be kind of ironic, since on the external keyboard the Fn key is near the numpad and not located near the ctrl key. – Rabarberski Jul 10 '20 at 12:52
  • On my MacBook Air I have 5 options including fn key, but on my MacBook Pro with the same operating system Mac OS 10.15.7 I only have 4 options NOT including the fn key – HerrNilsson Mar 30 '21 at 18:01
  • I don't see the FN key on mine either in that option menu. (Macbook pro 2019). So ridiculous. – munchschair Apr 13 '21 at 13:40
19

This is my white whale. I can't use Emacs without the control key being on the left hand side. Recently I got a new MacBook so I had a chance to do this without Karabiner.

This is what worked for me to rebind the function key to control (for the built-in keyboard only), on macOS 10.15.6.

hidutil property --matching '{ "ProductID": 0x027e }' --set '{
  "UserKeyMapping": [
    {
      "HIDKeyboardModifierMappingDst": 30064771300,
      "HIDKeyboardModifierMappingSrc": 1095216660483
    },
    {
      "HIDKeyboardModifierMappingDst": 30064771296,
      "HIDKeyboardModifierMappingSrc": 280379760050179
    }
  ]
}'

Verify it with hidutil property --matching '{ "ProductID": 0x027e }' --get "UserKeyMapping".

How I found these keycodes

I've both seen the option to change the Function (fn) Key and not seen the option to change the Function (fn) Key on the same computer, using the same version of macOS. Take it with a grain of salt, but I can consistently get the variant with the Function (fn) Key option to appear if I:

  1. Have an external keyboard attached, via a USB-Type C hub
  2. Open the Keyboard → Keyboard → Modifier Keys
  3. Lock the screen using the external keyboard
  4. Walk away for some time (wait until the computer sleeps)
  5. Wake the computer by pressing a key on the external keyboard and use Touch ID to log in
  6. Now the Modifier Keys preference has the Function (fn) Key option. While in this state, change the behaviour of the function key using the drop down list (I chose ^ Control)
  7. Copy ~/Library/Preferences/ByHost/.GlobalPreferences.${__UUID__}.plist (described here) somewhere else temporarily
  8. Convert the binary PList to XML: plutil -convert xml1 .GlobalPreferences.${__UUID__}.plist

Contents of that file are:

<?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>com.apple.keyboard.modifiermapping.1452-638-0</key>
    <array>
        <dict>
            <key>HIDKeyboardModifierMappingDst</key>
            <integer>30064771300</integer>
            <key>HIDKeyboardModifierMappingSrc</key>
            <integer>1095216660483</integer>
        </dict>
        <dict>
            <key>HIDKeyboardModifierMappingDst</key>
            <real>30064771296</real>
            <key>HIDKeyboardModifierMappingSrc</key>
            <integer>280379760050179</integer>
        </dict>
    </array>
</dict>
</plist>

This page shows up if you search for these HIDKeyboardModifierMappingSrc and says that 1095216660483 is for the left function key, 280379760050179 is for the right.

I thought I was going crazy so I took some screenshots for proof:

Modifier Keys preference pane without the Function (fn) Key option

Modifier Keys preference pane without the Function (fn) Key

Modifier Keys preference pane with the Function (fn) Key option

Modifier Keys preference pane with the Function (fn) Key

About ProductID

You can find the Product ID associated with your keyboard using the System Report button: Apple menu → System Report → Hardware → USB.

If you use the --matching parameter to hidutil using a specific Product ID, the changes will affect that piece of hardware only. For example, maybe you want to change the layout of the built-in keyboard, but not an external one.

enter image description here

eqyiel
  • 191
  • Excellent post, thanks very much - this answer deserves to be much higher as it does exactly what is asked without the overhead of additional software. – geedoubleya Sep 05 '20 at 20:21
  • 1
    Nice aswer! But it didn't work, unfortunately. Fn started to work as Ctrl, but kept also working as Fn, and Ctrl didn't work as Fn. I'm using the MacBook Pro 16 here, so it seems there is some hardwired stuff in this hardware, probably related to the touch bar. – Bruno Medeiros Sep 08 '20 at 03:57
  • I had the same problem as @BrunoJCM. This solution allowed me to map the Fn key to Ctrl, but it didn't map the Ctrl key to Fn. And when I press the Fn key, the function commands still pop up on the touch bar. – wheeler Nov 03 '21 at 23:17
  • 1
    This is super nice solution ! Thank you! I value your process of finding out the right things. Now, if we need other codes, one can use https://hidutil-generator.netlify.app to find out the mapping (not my work). – Ciprian Tomoiagă Nov 10 '21 at 15:00
  • @wheeler it seems some keyboards generate different codes for Fn. I've found out form here: https://github.com/amarsyla/hidutil-key-remapping-generator/issues/3 – Ciprian Tomoiagă Nov 10 '21 at 15:01
  • Is it possible only to allow fn+tab behave as control+tab? That would help me a lot, I don't need more mapping, just this one. – Marecky Dec 14 '21 at 13:41
6

you can use KeyRemap4MacBook

http://pqrs.org/macosx/keyremap4macbook/

you can find the included prepared settings list at this address:

http://pqrs.org/macosx/keyremap4macbook/list.html.en

as you can see there is the setting for Fn Key

Guido Preite
  • 3,541
3

I was happy, but then not as much. I just bought a Logitech K850 keyboard. Has a nice shape to help with wrist issues (for another time). Has keys from left as:

ctrl    fn    alt opt    cmd <butterfly>

Tried Karabiner but it didn't seem to work (tested by using ctrl-F in vi/vim). Then I found this document https://karabiner-elements.pqrs.org/docs/getting-started/features which lists a limitation.

Karabiner-Elements cannot modify the fn key on non Apple keyboards such as Logitech keyboards.

Not for Logitech. Ouch. Other suggestions? Back to best buy again? I'm really just looking for a mac layout keyboard with full size keys. I don't care about the num pad, etc. on right side. The K850 looked good except for this issue. Some gentle ergonomics help is good.

  • 1
    I am still using the K850 after more than a year. Though I cannot swap the ctrl and fn keys, I am very happy with this keyboard. I've grown accustomed to the layout and the feel is "oh so much" better than the macbook air 2018 laptop keyboard. FYI. – Alan Carwile Apr 28 '20 at 16:31
3

I'm a new Mac user so I don't know much about how this was solved before. But this seems to be fixed in MacOs Monterey 12.5 (MacBook Pro 16'' 2021). No third application required :)

Keyboard preferences

2

You could also add this to private.xml:

<autogen>__KeyToKey__ KeyCode::FN, KeyCode::CONTROL_L</autogen>
<autogen>__KeyToKey__ KeyCode::CONTROL_L, KeyCode::FN</autogen>

See the source for the key code values and predefined settings.

Lri
  • 105,117
1

In addition to trackpad gestures, Better Touch Tool allows you to remap individual keyboard combinations. I use it to remap fn ⇥ to ⌃ ⇥ and fn ⇧ ⇥ to ⌃ ⇧ ⇥.

Greg Perham
  • 1,495
1

Looks like the one way to make Karabiner work with Logitech keyboards is to uninstall Logi Options, but then:

  • the keyboard will behave like standard Apple keyboard - the mapping of function keys will differ from pictograms (I guess these can be remapped with Karabiner)
  • you will need to find another way to configure mouse buttons 3-5.
0

The hidutil-key-remapping-generator worked perfectly for me. You can access the tool online from hidutil key remapping generator for MacOS and copy the configuration to

~/Library/LaunchAgents/com.local.KeyRemapping.plist
agarza
  • 2,274