Score:0

Explain the internal mechanism of the "Keyboard Layout Options" from the aspect of the remapping of scancode, keycode, or keysym

jp flag

I would like you to explain the internal mechanism of the "Keyboard Layout Options" from the aspect of the remapping of scancode, keycode, or keysym. I am talking about the GUI "Keyboard Layout Options" control panel. I am particularly interested in Ubuntu MATE 20.04.

On Ubuntu MATE 20.04, the "Keyboard Layout Options" is located in the "Control Center" as shown below. Within "Keyboard Layout Options", I am particularly interested in "Ctrl is mapped to Win and the usual Ctrl keys", and "Swap Left Win with Left Ctrl".

Control Center > Hardware >

  Keyboard > Layout tab > Options... >

    Keyboard Layout Options

        Alt/Win key behavior

          (o)  Ctrl is mapped to Win and the usual Ctrl keys

        Ctrl position

          [v]  Swap Left Win with Left Ctrl

On Linux, there are three levels to identify keys -- scancode, keycode, and keysym. The scancode is the lowest level, and is what the keyboard sends to the computer. The keycode is the mid level. The keysym is the highest level.

Scancodes are more closely bound to positions on the keyboard than to the letters printed on the keys. For example, the key on which Y is printed on US keyboard has Z printed on it on European keyboard. However, the scancode is always the same no matter whether the key has Y printed on it on US keyboard or Z printed on it on European keyboard.

Commonly on Linux, there are two levels of mappings on Linux: the mapping from scancode to keycode, and the mapping from keycode to keysym. Thus, commonly on Linux, remapping of keys means either the modification of the scancode-to-keycode mapping or the modification of the keycode-to-keysym mapping.

On MS Windows, however, things are different from Linux. If I remember correctly, Windows lacks keysym. Nevertheless, scancode is the lowest level on Windows as well. On Windows, remapping of keys does not mean the modification of the scancode-to-keycode mapping but means the creation of extra mapping from scancode to scancode.

I would like to know whether the "Keyboard Layout Options" on Ubuntu MATE 20.04 is implemented as:

  • modification of the scancode-to-keycode mapping

  • modification of the keycode-to-keysym mapping

  • creation of extra mapping from scancode to scancode

  • or anything else (explain)

As stated above, I am particularly interested in "Ctrl is mapped to Win and the usual Ctrl keys", and "Swap Left Win with Left Ctrl".

Gunnar Hjalmarsson avatar
uz flag
MATE uses XKB for controlling the key mapping. The specific options you mention are both mentioned at `man xkeyboard-config`. To see it on a deeper level, you may want to study the files provided by the `xkb-data` package.
vanadium avatar
cn flag
Probably from evdev scancode to keysym
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.