Linux – How to use Control as modifier with xmodmap


So I'm trying to create a combination of keys to generate ISO keys for the Portuguese layout, the key in question is the < >, pressing it will normally generate the < character, < > + Shift will generate the > character. So I'm trying to create a combination using xmodmap, and I want this to work for all the programs. I've been searching on Google and came up with this example for Control + P = Up:

xmodmap -e "keycode 33 = p P Up"

keycode 33 matches p, so where does Control come up in that command?

What I want is:

  • map Control + , to >
  • map Control + . to <

Best Answer

  • The example from the other question is wrong.

    xmodmap -e "keycode 33 = p P Up"

    normally means that pressing AltGr + p will result in Up.

    More precisely it means that pressing Mode_switch + p will result in Up.

    As the xmodmap man page states:

    The first keysym is used when no modifier key is pressed in conjunction with
    this key, the second with Shift, the third when the Mode_switch key is used
    with this key and the fourth when both the Mode_switch and Shift keys are used.

    It is possible to map different or additional (to AltGr) as the Mode_switch key, e.g. the right Ctrl key:

    xmodmap -e "keycode 105 = Mode_switch Mode_switch"

    The problem however is that the key then won't work as normal Ctrl key anymore.

  • Related Question