Where did the Alt key go?

I just realized that my right Alt key is not working as an Alt key.

For example the right Alt + Left Arrow in Firefox does not go Back, and right Alt + Tab does not switch windows. These shortcuts work with the left Alt key though.

Using xev, the left Alt being pressed and released has this output:

KeyPress event, serial 34, synthetic NO, window 0x4a00001,
    root 0x67c, subw 0x0, time 5788950, (1222,352), root:(1222,416),
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x4a00001,
    root 0x67c, subw 0x0, time 5789044, (1222,352), root:(1222,416),
    state 0x8, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

But the right Alt key shows:

KeyPress event, serial 37, synthetic NO, window 0x4a00001,
    root 0x67c, subw 0x0, time 5793892, (1222,352), root:(1222,416),
    state 0x0, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
    XKeysymToKeycode returns keycode: 92
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 37, synthetic NO, window 0x4a00001,
    root 0x67c, subw 0x0, time 5793993, (1222,352), root:(1222,416),
    state 0x80, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
    XKeysymToKeycode returns keycode: 92
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

What is ISO_Level3_Shift ?? And what happened to Alt_R ?

1 Like

It seems to be a common issue:

> xmodmap -pke | grep -e "^keycode\s108\s"
keycode 108 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift NoSymbol ISO_Level3_Shift

A workaround: Xmodmap autostart

2 Likes

Someone encountered the same problem and wrote a detailed solution! Turns out Gnome decided to make Right Alt the Alternate Characters Key, as seen in Settings -> Keyboard Shortcuts.

The fantastic post detailing the problem and three solutions.

tl;dr

There are 3 possible solutions:

  1. navigate to Gnome’s Settings > Keyboard Shortcuts > Alternate Characters Key > Choose different key
  2. change the ‘lv3:ralt_switch’ setting to an alternate lv3 option (ie. ‘lv3:menu_switch’ sets this to the menu key instead)
  3. leave ‘lv3:ralt_switch’ set and also enable ‘lv3:ralt_alt’ to prevent Right Alt from ever choosing the 3rd level

I was trying to figure out why my right Alt key had been hijacked by ISO_Level3_Shift as well. The Gnome Tweak Tool’s Additional Layout Options didn’t indicate this should be set that way, nor did I see any options set in the output of localectl , so I was rather stumped until I stumbled across the solution today.

I just so happened to be changing a keyboard shortcut in Gnome and found the Alternate Characters Key setting in the Keyboard Shortcuts settings section. There I found that mine was set to Right Alt! I changed mine to the Menu key to test (my Thinkpad X1 Carbon doesn’t have an actual Menu key) and xev is now indicating that I have a right Alt key once again.

Further investigation lead me to discover that this is actually controlled by the ’ lv3:ralt_switch ’ xkb option, despite this not being reflected in Tweak Tool. It can be seen if the following gsettings key is queried…

$ gsettings get org.gnome.desktop.input-sources xkb-options

To test the various lv3 options without making the change permanent, use setxkbmap

$ setxkbmap -option 'lv3:ralt_alt'

Personally, I went with setting the ’ lv3:ralt_alt ’ option because there seem to be some conditions (that I haven’t nailed down) where it gets reverted back to using Right Alt again. I did so globally using localectl

$ localectl set-x11-keymap us '' '' 'lv3:ralt_alt'

To see all the lv3 options available, localectl may be used as well…

$ localectl list-x11-keymap-options | grep lv3

If you want to know what each of these settings actually does, the only place I’ve found descriptions of these various options is in the base.lst file, which is owned by the xkeyboard-config package…

/usr/share/X11/xkb/rules/base.lst

Hopefully this might save someone else a bit of time and effort in trying to figure out why Gnome hates Right Alt so much.

EDIT : It turns out that Gnome and gdm actually ignore the settings written to /etc/X11/xorg.conf.d/00-keyboard.conf by localectl . So rather than setting it globally, I had to set this for just my own user with gsettings in order to get these settings to take (I’ve included more than just the one xkb option setting in the example below to show the syntax if wanting to set multiple options)…

$ gsettings set org.gnome.desktop.input-sources xkb-options "['lv3:ralt_atl', 'compose:prsc', 'terminate:ctrl_alt_bksp']"

Also, I had hit a scenario where the reestablished Right Alt key correctly reports being a Alt_R key press, but it isn’t actually functioning as an Alt key. Turned out that it was because it wasn’t also defined in the list of modifier keys (ie. shown by xmodmap -pm output). But a subsequent reboot seems to have fixed it and I can’t seem to even get it back to that wonky state. So probably nothing to worry about, but just fair warning.

Source: https://bbs.archlinux.org/viewtopic.php?id=254313

2 Likes