How to swap F keys and Fn keys?

Hi guys, on my laptop the FN keys are not disabling in the bios. How can I disable this button softwarly and use F1-F12 keys like on macbook?

Hi @peaceduke, and welcome!

From https://superuser.com/a/775811 :

  1. Connect a USB keyboard in there, or get into the machine using ssh.
  2. Open a terminal, and run xev -event keyboard. It will show some stuff on screen. If you omit the arguments, you will notice that it will show some more stuff if you move your mouse, as well.
  3. Then, press the key combination you want to disable [é]. The info in the screen will change, and you will have to look for the keycode value.
  4. Run something like this, changing <value> for the value you got for the keycode in the last step:
xmodmap -e 'keycode <value>='

For example, if I want to disable the ~ key ( Shift + ` ), I would have to run:

xmodmap -e 'keycode 49='

Hope this helps!

And how should we figure what laptop is that? Really…

Usually it’s Fn+Esc though.

Ignore this. Damn I'm stupid today!

Well, there’s this:

It’s also why I don’t think the “Normal” shortcut(s) will work.

Have a look here: Apple Keyboard - ArchWiki

Edit: Oh, so it isn’t a macbook… then ignore this too!

1 Like

Do you use wayland or X11? What layout do you use?

If there’s no option in the BIOS/UEFI, then you’ll have to do it in xkb (xmodmap should also work if you use X11).

You can copy your layout and edit it, this should work for wayland and X11.

Layouts are in /usr/share/X11/xkb/symbols.

Since we don’t know what layout you’re using, I’ll use the gb layout as an example.

We can use xev -event keyboard to figure out what key we want.

KeyPress event, serial 28, synthetic NO, window 0x3e00001,
    root 0x6a9, subw 0x0, time 233464, (117,64), root:(711,361),
    state 0x10, keycode 172 (keysym 0x1008ff14, XF86AudioPlay), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

The keycode and keysym are what we’re looking for. Below will remap the Play/Pause key to F7 and vice versa. In this case there are 2 keysyms for Play/Pause. They can be found using xkbcomp $DISPLAY ~/xkbmap in X11 (easiest way), the rest of the keys will probably only have 1 keysym.

key <I172> {
        type= "CTRL+ALT",
        symbols[Group1]= [              F7,              F7,              F7,              F7, XF86Switch_VT_7 ]
    };

key <FK07> {         [   XF86AudioPlay,  XF86AudioPause ] };

So we can add that into a copy of gb (still in /usr/share/X11/xkb/symbols), you can call it whatever you like:

default partial alphanumeric_keys
xkb_symbols "basic" {

    // The basic UK layout, also known as the IBM 166 layout,
    // but with the useless brokenbar pushed two levels up.

    include "latin"

    name[Group1]="English (UK)";

    key <TLDE>  { [     grave,    notsign,          bar,          bar ] };
    key <AE02>  { [         2,   quotedbl,  twosuperior,    oneeighth ] };
    key <AE03>  { [         3,   sterling, threesuperior,    sterling ] };
    key <AE04>  { [         4,     dollar,     EuroSign,   onequarter ] };

    key <AC11>  { [apostrophe,         at, dead_circumflex, dead_caron] };
    key <BKSL>  { [numbersign, asciitilde,   dead_grave,   dead_breve ] };

    key <LSGT>  { [ backslash,        bar,          bar,    brokenbar ] };

    key <I172> {
        type= "CTRL+ALT",
        symbols[Group1]= [              F7,              F7,              F7,              F7, XF86Switch_VT_7 ]
    };


    key <FK07> {         [   XF86AudioPlay,  XF86AudioPause ] };


    include "level3(ralt_switch)"
};

Then you select that layout in your keyboard settings.

EDIT:

I forgot about the TTYs, they don’t use xkb. So it may be better to map scancodes to keycodes.

In addition, my F12 turns wifi and bluetooth on and off (XF86RFKill). I tested this, and whilst I can switch the keys it still kills wifi/bluetooth, so it seems to be internal to the laptop.

1 Like

Have you checked the manual? Many laptops, 65% keyboards or media-centric keyboards got a key combo to “caps lock” FN. It’s only anecdotal evidence, but I got notebooks from DELL, HP and also a “Microsoft All-in-One Media Keyboard” which all have such a key combo. The notebooks even remember the FN lock after rebooting / shutdown.