Modify your keyboard settings with Xmodmap


Commands, programs, there are many, each one for a particular application. Many of us think if they will really be useful at some point, and suddenly the day comes when that precise command is the one that can help us.

Although I have considered this command useful from the beginning, perhaps many have not. But in reality there are endless reasons why it would be necessary change your computer keyboard settings. If you need to access a special character more immediately, or if you have a keyboard with a damaged key, in short, the truth is that it is necessary or not, here are various methods to modify the keyboard of your computer at your convenience.

Table of Contents


To begin with, Xmodmap is in charge of controlling the mapping between each key that is pressed on the keyboard, and the response of the system to the action, for example, to what we see on the screen. For this, xmodmap makes use of two important parameters: the "KeyCodes" and the "KeySym".

Each KeyCodes They are numbers generated by the keyboard when you press a certain key, and define only each key. For example, in my case the space key is represented by KeyCode 65.

Furthermore, the KeySyms are words used to define a key type. In this way, Xmodmap does not need to directly interpret the information output from the keyboard, but can also refer to the keys by name. Continuing with the example, my spacebar has a KeyCode of 65, and its KeySym is "space".

Can you help yourself with the command xev, which allows you to know the keycode and keysym of each key you press, or else, you can always use the command xmodmap -pke where you will see a list of all the keys along with their keycodes and keysym.

There is a third parameter that Xmodmap considers, and it is that of modifiers. These correspond to the group of special keys that are pressed at the same time as another key to change its output. For example Shift, Caps_Lock, Ctrl, etc.

In order to perform the keyboard modification, we will first understand how the Xmodmap command works. If we execute

xmodmap -pke

We will observe each keysym corresponding to each keycode on the keyboard, with a format similar to this:

[…] Keycode 57 = KeySym1 KeySym2 KeySym3...


Where each column of KeySym corresponds to the combination of the following modifier keys:

1. Key
2. Shift + Key
3. mode_switch + Key
4. mode_switch + Shift + Key
5. AltGr + Key
6. AltGr + Shift + Key

So, as an example, if we wanted to change the key caps LOCK, so that it works like Shift, we execute the following line.

Xmodmap -e "keycode 66 = Shift_L"

And from now on, the uppercase block (Keycode 66) will work as a Shift_L.

Similarly, if you want to configure a character with the Shift combination, you only have to modify column two of the KeySym, and so on according to the table.


Trying to make life a little simpler, xmodmap also has a graphical interface, pleasant for the user to make changes to the keyboard configuration. Xkeycaps is presented with a window that allows you to select the keyboard model to use and, in turn, make changes between keys graphically.


Xkeycaps allows you to:

  • Edit the KeySym of a key
  • Swap keys
  • Duplicate Keys
  • Disable keys
  • Restore Defaults

Console or graphical interface, xmodmap or xkeycaps, here are two options to organize each key on your computer in your own way.

The content of the article adheres to our principles of editorial ethics. To report an error click here!.

9 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *



  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Pasadeno said

    And what would be the orthodox way of mapping the keyboard at ease, both in a graphical environment and in console mode, from minute 0? Because I understand that these commands do not make a permanent change.

    It occurs to me to use files like /etc/rc.local or ~ / .bashrc, but it would be more of a hack to get out of trouble.

  2.   Bill said

    Excellent applications, I did not know the one that comes with a graphical interface. Certainly I used Xmodmap to add Esperanto characters when before 2009 they weren't within our reach, yes (ŝĉĥĵĝ they are easy although ŭ is still difficult with ALT GR + SHIFT + ç).

    Add that until 2009 you could modify everything in a text file and you could copy the xmodmap file to the user's folder / home / USER with a point in front to hide it: .xmodmap-eo for example to put keys in Esperanto (eo) and when logging in, the system asked whether to modify the keyboard with that version.

    Does anyone know if it is still easy to change keys with a text editor or do you necessarily have to use an intermediate program? And is it changed for a specific user or for everyone who uses the system?

    This like changing the Grub, before in a text file and now to compile and everything.

  3.   ignacio said

    $ xmodmap -e "keycode 66 = Shift_L"
    xmodmap: unknown command on line commandline: 1
    xmodmap: unable to open file '66' for reading
    xmodmap: unable to open file '=' for reading
    xmodmap: unable to open file 'Shift_L ”' for reading
    xmodmap: 4 errors encountered, aborting.

  4.   Japanese said

    I have a similar problem, the Ctrl and Alt keys mark me as Shift whether they are left or right. and I do not know how to give them the correct value, if someone knows a lot I appreciate it, tell me. Japo

  5.   Juanito said

    Help I need to exchange my p key for the ñ with the graphic application it works but the changes are not saved when restarting

  6.   Gumersindo Guerrero said

    hello, after locking one of the keys with the xkeycaps, how to make the change permanent, since once the change is restarted it does not reflect it.

    Thank you

  7.   Daniel Jimenez said

    It works perfectly, but once you restart the computer, these changes are lost.
    How can I make them permanent?

  8.   Turo said

    An additional piece of information: The modifier key «Fn» (function) that usually comes in all laptops (laptops) would correspond to the seventh column so:

    1. Key
    2. Shift + Key
    3. mode_switch + Key
    4. mode_switch + Shift + Key
    5. AltGr + Key
    6. AltGr + Shift + Key
    7. Fn

    This key is usually assigned the KeySym associated with the multimedia keys sometimes drawn above the F1-12 keys (on my WisFox keyboard XF86Switch_VT_1 to XF86Switch_VT_12). On my keyboard the F1 key shows the following:

    keycode 67 = F1 F1 F1 F1 F1 F1 XF86Switch_VT_1

    and this XF86Switch_VT_1 in the key appears an icon of two eighth notes (two musical notes) that opens the music player.
    Some apparently also have predefined functions (XF86XK_AudioMute mutes the sound) and the interesting thing would be to make use of any other key that does not have this modifier assigned to have another "page" or keyboard rollover for whatever we like. At the moment I would not know how to do it ...

    I hope it helps a colleague who also wants to get the most out of his keyboard without buying a new one with a greater number of keys.

  9.   Juan C. said

    Thanks for the article Gerak, I don't know if the author of this article is still writing but although this article is from years ago, today 2021 was useful to me, thanks for taking the time to write, for the screenshots, and also for having added the option of being able to do this configuration from an application with a graphical interface.