There seem to be few examples for how to use xmodmap to bind a modifier + some key, to a new key.

E.g. I want to bind left Shift (keycode 50) + ` (keycode 21) to emit a grave accent character:


This is the normal behavior for a Norwegian keyboard, but not on a Macbook Pro (running Linux).

I'm using xev to get the keycodes, I can successfully map single key presses (with the help from another post which I cannot find) to get essential other keys, e.g. backspace and dollar sign in this manner:

keycode 134 = ISO_Level3_Shift Multi_key ISO_Level3_Shift Multi_key
keycode 21 = backslash bar

However how do I do:

keycode 50 + keycode 21 = Grave character

This is not the correct syntax but it should make what I want clear.

In general how is a modifier key like shift used correctly in the syntax? Can only modifier keys be used in combinations?

I've tried simple things such as "keycode 50 keycode 21 = A" and "keycode 50 + keycode 21 = A". ("A" is not the character I want, I'm just using it for test purposes).


1 Answer 1


Key chords (like Shift+\) are specified by combining one key with a set of modifiers, not by combining keys directly. So rather than “keycode 50 plus keycode 21”, what you need to specify is “keycode 21 plus the Shift modifier”. Only modifiers can be used in combinations. Furthermore xmodmap is somewhat limited: you need to specify all the key chords for a particular base key at the same time.

keycode 21 = backslash grave acute

The first keysym (character or function key name) after the equal sign is the one corresponding to the bare key, then comes the one corresponding to the key with Shift, then with AltGr, then with Shift+AltGr.

If you want dead keys, then change this to

keycode 21 = backslash dead_grave dead_acute

If you want a standard Norwegian layout, though, you should be able to select it in your desktop environment's configuration interface, or with XKB — setxkbmap -layout no switches to a Norwegian layout.

  • Thanks. So since there is no AltGr key on the Macbook keyboard, I would also need to bind this "cmd" key (or whatever key I prefer to use, I prefer this, since that is where AltGr is supposed to be) to AltGr, and then acute/dead_acute should also work as on a normal keyboard? Commented Feb 16, 2015 at 0:54
  • @AttributedTensorField Set keycode … = Mode_switch where is the key code of the key you want to bind to AltGr. Use xev to find the right keycode. Commented Feb 16, 2015 at 13:35

You must log in to answer this question.

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