Post History
It is true that Fn combinations are usually implemented in hardware, but in X11 (not Wayland of course!) you can circumvent this issue for most or all your keys.[1] For example, my F3 -> F3 and...
Answer
#3: Post edited
It is true that Fn combinations are usually implemented in hardware, but in X11 (not Wayland of course!) you can circumvent this issue for most or all your keys¹.- For example, my `F3 -> F3` and my `Fn+F3 -> {Switch monitor}`.
- ### Find out the keycodes of the keys
- In a terminal, launch `xev`. Press Fn+F3 and see the output in the terminal:
- ```
- KeyRelease event, serial 32, synthetic NO, window 0x1400001,
- root 0x25a, subw 0x0, time 11205128, (-592,394), root:(2,689),
- state 0x0, keycode 235 (keysym 0x1008ff59, XF86Display), same_screen YES,
- ```
- So the keycode for **Fn+F3 is 235**. Repeat the steps for F3 to determine that the keycode for **F3 is 69**.
### Dump your XKB map to a file```- xkbcomp "$DISPLAY" xkb
- ```
- ### Swap the keycodes in the map
- Open the created `xkb` file in your text editor.
- In the `xkb_keycodes` section of the file, swap the keycode 69 <-> 235. I.e., if the section looks like this initially,
- ```
- <FK01> = 67;
- <FK02> = 68;
- <FK03> = 69;
- [...]
- <I235> = 235;
- <I236> = 236;
- <I237> = 237;
- ```
- it should look like this afterwards:
- ```
- <FK01> = 67;
- <FK02> = 68;
- <FK03> = 235;
- [...]
- <I235> = 69;
- <I236> = 236;
- <I237> = 237;
- ```
### Load your new XKB map```- xkbcomp xkb "$DISPLAY"
- ```
- Now `F3 -> {Switch monitor}` and `Fn+F3 -> F3`.
Further reading: https://wiki.archlinux.org/title/X_keyboard_extension<sub>1 This won't work for combinations that also work directly via hardware, for example, in my computer Fn+F2 will turn the screen on or off. If `xev` doesn't detect the combination, you are out of luck — unless it is detected by `acpi_listen` and you can contrive something... food for thought, I really did not try.
- It is true that Fn combinations are usually implemented in hardware, but in X11 (not Wayland of course!) you can circumvent this issue for most or all your keys.[^key-hardware]
- For example, my `F3 -> F3` and my `Fn+F3 -> {Switch monitor}`.
- ### Find out the keycodes of the keys
- In a terminal, launch `xev`. Press Fn+F3 and see the output in the terminal:
- ```
- KeyRelease event, serial 32, synthetic NO, window 0x1400001,
- root 0x25a, subw 0x0, time 11205128, (-592,394), root:(2,689),
- state 0x0, keycode 235 (keysym 0x1008ff59, XF86Display), same_screen YES,
- ```
- So the keycode for **Fn+F3 is 235**. Repeat the steps for F3 to determine that the keycode for **F3 is 69**.
- ### Dump your [XKB][] map to a file
- ```sh
- xkbcomp "$DISPLAY" xkb
- ```
- ### Swap the keycodes in the map
- Open the created `xkb` file in your text editor.
- In the `xkb_keycodes` section of the file, swap the keycode 69 <-> 235. I.e., if the section looks like this initially,
- ```
- <FK01> = 67;
- <FK02> = 68;
- <FK03> = 69;
- [...]
- <I235> = 235;
- <I236> = 236;
- <I237> = 237;
- ```
- it should look like this afterwards:
- ```
- <FK01> = 67;
- <FK02> = 68;
- <FK03> = 235;
- [...]
- <I235> = 69;
- <I236> = 236;
- <I237> = 237;
- ```
- ### Load your new [XKB][] map
- ```sh
- xkbcomp xkb "$DISPLAY"
- ```
- Now `F3 -> {Switch monitor}` and `Fn+F3 -> F3`.
- ### Further reading
- - [X keyboard extension (xkb)][xkb] on the Arch wiki
- [^key-hardware]: This won't work for combinations that also work directly via hardware, for example, in my computer Fn+F2 will turn the screen on or off. If `xev` doesn't detect the combination, you are out of luck — unless it is detected by `acpi_listen` and you can contrive something... food for thought, I really did not try.
- [xkb]: https://wiki.archlinux.org/title/X_keyboard_extension
#2: Post edited
It is true that FN is usually implemented in hardware, but in X11 (not Wayland of course!) you can circumvent this issue for most or all your keys¹.For example, my `F3 -> F3` and my `Fn+F3 -> {Switch monitor}`. First thing, I should find out what is the keysym corresponding to that special function.So in a terminal I launch `xev`, press Fn+F3 and see in the terminal output- ```
KeyRelease event, serial 36, synthetic NO, window 0x1200001,root 0x25a, subw 0x0, time 8585736, (-192,109), root:(402,404),state 0x0, keycode 69 (keysym 0x1008ff59, XF86Display), same_screen YES,- ```
XF86Display is the keysym I'll want a few steps later.I run- ```
- xkbcomp "$DISPLAY" xkb
- ```
and, looking for F3 and XF86Display (that's why we used `xev`), I find in output.xkb these blocks:- ```
key <FK03> {type= "CTRL+ALT",symbols[Group1]= [ F3, F3, F3, F3, XF86Switch_VT_3 ]};- ```
- ```
key <I235> { [ XF86Display ] };- ```
So all you need to do is to swap the values inside the angled brackets, save the file and run- ```
- xkbcomp xkb "$DISPLAY"
- ```
Now my `F3 -> {Switch monitor}` and my `Fn+F3 -> F3`.- Further reading: https://wiki.archlinux.org/title/X_keyboard_extension
- <sub>1 This won't work for combinations that also work directly via hardware, for example, in my computer Fn+F2 will turn the screen on or off. If `xev` doesn't detect the combination, you are out of luck — unless it is detected by `acpi_listen` and you can contrive something... food for thought, I really did not try.
- It is true that Fn combinations are usually implemented in hardware, but in X11 (not Wayland of course!) you can circumvent this issue for most or all your keys¹.
- For example, my `F3 -> F3` and my `Fn+F3 -> {Switch monitor}`.
- ### Find out the keycodes of the keys
- In a terminal, launch `xev`. Press Fn+F3 and see the output in the terminal:
- ```
- KeyRelease event, serial 32, synthetic NO, window 0x1400001,
- root 0x25a, subw 0x0, time 11205128, (-592,394), root:(2,689),
- state 0x0, keycode 235 (keysym 0x1008ff59, XF86Display), same_screen YES,
- ```
- So the keycode for **Fn+F3 is 235**. Repeat the steps for F3 to determine that the keycode for **F3 is 69**.
- ### Dump your XKB map to a file
- ```
- xkbcomp "$DISPLAY" xkb
- ```
- ### Swap the keycodes in the map
- Open the created `xkb` file in your text editor.
- In the `xkb_keycodes` section of the file, swap the keycode 69 <-> 235. I.e., if the section looks like this initially,
- ```
- <FK01> = 67;
- <FK02> = 68;
- <FK03> = 69;
- [...]
- <I235> = 235;
- <I236> = 236;
- <I237> = 237;
- ```
- it should look like this afterwards:
- ```
- <FK01> = 67;
- <FK02> = 68;
- <FK03> = 235;
- [...]
- <I235> = 69;
- <I236> = 236;
- <I237> = 237;
- ```
- ### Load your new XKB map
- ```
- xkbcomp xkb "$DISPLAY"
- ```
- Now `F3 -> {Switch monitor}` and `Fn+F3 -> F3`.
- Further reading: https://wiki.archlinux.org/title/X_keyboard_extension
- <sub>1 This won't work for combinations that also work directly via hardware, for example, in my computer Fn+F2 will turn the screen on or off. If `xev` doesn't detect the combination, you are out of luck — unless it is detected by `acpi_listen` and you can contrive something... food for thought, I really did not try.
#1: Initial revision
It is true that FN is usually implemented in hardware, but in X11 (not Wayland of course!) you can circumvent this issue for most or all your keys¹. For example, my `F3 -> F3` and my `Fn+F3 -> {Switch monitor}`. First thing, I should find out what is the keysym corresponding to that special function. So in a terminal I launch `xev`, press Fn+F3 and see in the terminal output ``` KeyRelease event, serial 36, synthetic NO, window 0x1200001, root 0x25a, subw 0x0, time 8585736, (-192,109), root:(402,404), state 0x0, keycode 69 (keysym 0x1008ff59, XF86Display), same_screen YES, ``` XF86Display is the keysym I'll want a few steps later. I run ``` xkbcomp "$DISPLAY" xkb ``` and, looking for F3 and XF86Display (that's why we used `xev`), I find in output.xkb these blocks: ``` key <FK03> { type= "CTRL+ALT", symbols[Group1]= [ F3, F3, F3, F3, XF86Switch_VT_3 ] }; ``` ``` key <I235> { [ XF86Display ] }; ``` So all you need to do is to swap the values inside the angled brackets, save the file and run ``` xkbcomp xkb "$DISPLAY" ``` Now my `F3 -> {Switch monitor}` and my `Fn+F3 -> F3`. Further reading: https://wiki.archlinux.org/title/X_keyboard_extension <sub>1 This won't work for combinations that also work directly via hardware, for example, in my computer Fn+F2 will turn the screen on or off. If `xev` doesn't detect the combination, you are out of luck — unless it is detected by `acpi_listen` and you can contrive something... food for thought, I really did not try.