Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I mapped my AltGr key to Ctrl with the following command:

setxkbmap -option ctrl:ralt_rctrl

However, when displaying the bindings with

xmodmap -pke

I can see that the keycode is associated to

   keycode 108 = Control_R Control_R Control_R Control_R

I would like to bind AltGr to LEFT Control. Is it possible?

This is important for Emacs, otherwise I don't get the same input when pressing C-S-b with the original Left Control or with AltGr.

share|improve this question
For those who might not know: 'AltGr' is the right hand 'Alt' key so labelled e.g. on a German keyboard. – Anthon Jun 20 '13 at 7:10
up vote 0 down vote accepted

It maps to Control_R as that's how it's configured in XKB symbols for CTRL. Changing the configuration should result in Alt_R being mapped to Control_L. Note that with this method, your custom configuration will be overwritten by any future upgrades of xkeyboard-config (at least that's the package that owns /usr/share/X11/xkb/symbols/ctrl in Archlinux).
Open /usr/share/X11/xkb/symbols/ctrl, scroll down to this section:

// right alt functions as another ctrl key
partial modifier_keys 
xkb_symbols "ralt_rctrl" {
    replace key <RALT> { type[Group1]    = "TWO_LEVEL",
                         symbols[Group1] = [ Control_R, Control_R ] };
    modifier_map Control { <RALT> }; 

and replace Control_R with Control_L so that it reads:

// right alt functions as another ctrl key
partial modifier_keys 
xkb_symbols "ralt_rctrl" {
    replace key <RALT> { type[Group1]    = "TWO_LEVEL",
                         symbols[Group1] = [ Control_L, Control_L ] };
    modifier_map Control { <RALT> }; 

save & restart X then run:

setxkbmap -option ctrl:ralt_rctrl

check with xmodmap:

xmodmap -pke | grep 108
keycode 108 = Control_L Control_L Control_L Control_L

To make it permanent add setxkbmap -option ctrl:ralt_rctrl to your session start-up.
Alternatively, add ctrl:ralt_rctrl to your xorg.conf.d config files, e.g.:

Section "InputClass"
    Identifier         "Keyboard Defaults"
    MatchIsKeyboard    "yes"
    Driver             "evdev"
    Option             "XkbLayout" "us"
    Option             "XkbRules"  "evdev"
    Option             "XkbOptions" "ctrl:ralt_rctrl"

Note to Gnome users: Gnome overrides xorg XKB options so one has to add ctrl:ralt_rctrl via gsettings (or dconf-editor):

gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:ralt_rctrl']"
share|improve this answer
I still get Control_R after a reboot: xmodmap -pke |grep 108 keycode 108 = Control_R Control_R Control_R Control_R Also a "No such schema 'org.gnome.desktop.input-sources'" error with gsettings. Any idea? – z1naOK9nu8iY5A Jun 25 '13 at 15:45
I'm using Ubuntu 12.04 with Gnome and a french layout. – z1naOK9nu8iY5A Jun 25 '13 at 17:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.