How can I change key bindings for a single key? I know that there are software like xmodmap and so on, but with this I can't map my key bindings, because with xmodmap I first have to press the keys that I want to change, but I can't because the key f doesn't work anymore. So I just want to change f (which doesn't work) to another, more useless key. How to do that? Thx

1 Answer 1


Xmodmap doesn't need "to press the keys". Did you read man xmodmap(1)?

All you have to do is to set key, like for example F12 to f.

$ xmodmap -pke | grep F12
keycode  96 = F12 F12 F12 F12 F12 F12 XF86Switch_VT_12 F12 F12 XF86Switch_VT_12
$ xmodmap -e "keycode 96 = f F"

First line shows keycode for F12 and second (command) sets keycode 96 to be 'f'.

You can see all keycodes with -pke option. It can also be used as backup.

# save current key map to file:
$ xmodmap -pke > xmodmap.bak

# you can view it with:
$ less xmodmap.bak

# restore from backup:
$ xmodmap xmodmap.bak

Last thing you have to do is put it in ~/.Xmodmap so your setting will load automatically with X server start.

$ echo "keycode 96 = f F f F" >> ~/.Xmodmap

This should hopefully solve automatic load of the setting.


Check xmodmap Arch wiki or xmodmap tutorial for reference.

  • Hi, Thx For answer, but it didn't work. F12 makes more brightness (F11 lower). keycode is now 96 = F f F f " but it still doesn't work.
    – user117640
    Commented May 27, 2021 at 17:15
  • Seems like F12 is not keycode 96 on your keyboard. Check updated answer to find out more. You should easily get to what is wrong with your command line.
    – tansy
    Commented May 27, 2021 at 19:49
  • Show us result of $ xmodmap -pke | grep F12.
    – tansy
    Commented May 27, 2021 at 19:54

You must log in to answer this question.

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