1

How to swap the keys and make Left Alt act like AltGr as well? I tried xmodmap with the following:

clear mod1
clear mod5
keycode 108 = Alt_L Meta_L
keycode 64 = Alt_R Meta_R
add mod1 = ISO_Level3_Shift
add mod5 = Alt_L Meta_L

but it doesn't work. Output from xev when I hit left Alt is

KeyRelease event, serial 38, synthetic NO, window 0xb000001,
    root 0x1e0, subw 0x0, time 70149128, (43,110), root:(3464,565),
    state 0x18, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,

And for right Alt is

KeyPress event, serial 38, synthetic NO, window 0xb000001,
    root 0x1e0, subw 0x0, time 70149484, (43,110), root:(3464,565),
    state 0x10, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,

I saw people try using ISO_Level3_Shift: Is there a way to remap the AltGr key to Ctrl with setxkbmap? and xmodmap: https://askubuntu.com/questions/93624/how-do-i-swap-left-ctrl-with-left-alt-on-my-keyboard but it's not enough. The documentation of xmodmap sucks.

1
  • I did keycode 64 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift NoSymbol ISO_Level3_Shift ISO_Level3_Shift keycode 108 = Alt_L Meta_L Alt_L Meta_L Alt_L Meta_L Alt_L Meta_L and it maybe works. Can someone explain it?
    – banan3'14
    Commented May 5, 2021 at 18:38

1 Answer 1

3

In man xkeyboard-config, Key to choose the 3rd level, several options are listed to modify access to the 3rd level.

lv3:alt_switch             Any Alt
lv3:lalt_switch            Left Alt
lv3:ralt_switch            Right Alt
lv3:ralt_switch_multikey   Right Alt; Shift+Right Alt as Compose
lv3:ralt_alt               Right Alt never chooses 3rd level

Thus

setxkbmap -option lv3:lalt_switch -option lv3:ralt_alt

makes the left Alt access 3rd level and right Alt an ordinary Alt.

Put the command in a start-up script to make it persistent, or in Debian based systems include the options in /etc/default/keyboard:

XKBOPTIONS="lv3:lalt_switch,lv3:ralt_alt"

You must log in to answer this question.

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