Bind context menu key in Linux

Some keyboards miss context menu key. To bind right alt as context menu:

xmodmap -e "keycode  108 = Menu"

Persistance

Given commend will have effect until x.org restart. After test that proves that by pushing right alt context menu called, settings should be persisted.

xmodmap -pke > ~/.Xmodmap

will create .Xmodmap file or rewrite it with current keys configuration.

Than one should make sure that ~/.Xmodmap included in ~/.xinitrc. Here is example from Manjaro:

usermodmap=$HOME/.Xmodmap
if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

Key choice

If other than right alt button needed, one should call

xev | grep keycode

and press needed button. For example here is output for pressed spacebar:

state 0x10, keycode 65 (keysym 0x20, space), same_screen YES,
published 2021-03-14 13dagger