I want to change the behavior of the Alt_L key on my keyboard (keycode 64) so that it has the same behavior as the Alt_R (keycode 108 or Alt gr) on Ubuntu 22.04.
the output of the following command xmodmap -pke
is the following
keycode 64 = Alt_L Meta_L Alt_L Meta_L
keycode 108 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift
I read the following pages
https://superuser.com/questions/53092/gnome-map-altgr-key-to-alt
How can I change what keys on my keyboard do? (How can I create custom keyboard commands/shortcuts?)
and try the following commands:
xmodmap -e "clear Alt_L"
xmodmap -e "keycode 64 = ISO_Level3_Shift"
First I get the following error message:
xmodmap: commandline:1: bad clear modifier name 'alt_l'
xmodmap: 1 error encountered, aborting.
I then re-run the following command xmodmap -pke
with the following output
keycode 64 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift
keycode 108 = ISO_Level3_Shift NoSymbol ISO_Level3_Shift
So to me it seems that the key was successfully remapped, however, the behaviour does not change
I saw that there was a very similar question in which some comments seem to indicate that it could be related to a bug
Ubuntu+1: How to map ALT Gr key as ALT R on Ubuntu 20.04?
EDIT 1
I also saw the following question
Left Alt key should work as right Alt key (Alt Gr)
As I want to remap caps lock to escape, I used the combination of those commands:
dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:escape']"
dconf write /org/gnome/desktop/input-sources/xkb-options "['lv3:lalt_switch','lv3:ralt-alt']"
and
gsettings set org.gnome.desktop.input-sources xkb-options "['caps:escape']"
gsettings set org.gnome.desktop.input-sources xkb-options "['lv3:lalt_switch','lv3:ralt-alt']"
however, with the 2 last solutions, only the last command is effective but the first one does not work
EDIT 2
According to this question, it is not possible to use xmodmap in Ubuntu anymore:
Permanent xmodmap in Ubuntu 13.04
If this is the case it is rather sad because it is then not possible to use troubleshooting tool such as xev
How could I solve the problem?
partial answer
What worked for me was to put the three commands in the same line :
dconf write /org/gnome/desktop/input-sources/xkb-options "['lv3:lalt_switch','lv3:ralt-alt', 'caps:escape']"
However that does not solve the important question about how to use xev
for trouble shooting