Please note: This is not a duplicate as the fn key behaves differently than other keys on the keyboard. I can't get the fn keycode by using, for example, xev.

I'm running Xubuntu 16.04 on my Macbook now, with UK keyboard layout for input, which works fine and has all the keys in the correct positions.

The one thing I never got used to on my Macbook is that the fn and Ctrl keys are swapped over from what you would usually see in most UK laptops' keyboard layouts.

enter image description here

Can I reconfigure my keyboard layout in Ubuntu so that the fn key in the picture above becomes Ctrl, and vice-versa (while keeping all others keys exactly the same)?

This is tricky because the fn key doesn't seem to behave like other keys. You can't get the fn keycode by running xev. Every other answer to this question I've found doesn't apply when dealing with the fn key, as they depend on getting the keycode from xev.

How can I remap fn to Ctrl and vice-versa?

I will welcome any "hackish" idea or solution.

  • 2
    Fn keys generate ACPI events and not keyboard events. sudo acpi_listen and press a Fn + volUp will show button/volumeup VOLUP 00000080 00000000 K. It connects directly to the hardware so is OS independent. Remapping probably is out of the question.
    – Rinzwind
    Sep 21, 2016 at 18:57
  • Take out the probably and make it an answer. It's brilliant and concise as it is.
    – user589808
    Sep 21, 2016 at 19:03
  • I finally found something that works for me: github.com/free5lot/hid-apple-patched
    – Bill Moon
    Jun 8, 2018 at 1:11

2 Answers 2


Fn keys generate ACPI events and not keyboard events. To echo the keypress for Fn to the terminal use ...

sudo acpi_listen

Pres Fn + F12 and it will show

button/volumeup VOLUP 00000080 00000000 K. 

This connects directly to the hardware and is OS independent. Remapping is out of the question.

Here is an interesting read about kernel and a keymap. But that goes beyond a basic changing of keycodes and it does not deal with setting the control key to act as an Fn.

  • 1
    How can I remap which fn combinations correlate with actions? Apr 3, 2017 at 22:40
  • On Arch: sudo pacman -S acpid && sudo systemctl start acpid && acpi_listen
    – jpoppe
    Dec 26, 2018 at 13:16

Sorry if I'm late to the party.

Since you are using an Apple keyboard, you can use the free5lot's hid-apple-patched to swap this two keys, and also perform a couple of other remaps (fnmode, swap_fn_leftctrl, swap_opt_cmd, rightalt_as_rightctrl, ejectcd_as_delete).

It works with the built-in keyboard and also with magic keyboards

The installation instructions are pretty straightforward.

P.S.: I personally just tested it with US layouts, but should work with UK variants as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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