12

I'm using a German Apple keyboard on my Ubuntu 12.04 machine. Under Mac OS X the left Alt key has the same behavior as the right Alt key (I think the right Alt key acts as the AltGr). I don't know what I must remove from the mapping to clear the left Alt key and what I must add that the left Alt key acts the same way as the right Alt key?

My questions are:

  • How can I get the current mapping of the right Alt key?
  • And how can I assign it to the left Alt key?
4
  • Could I ask why you want that? all shortcut with ALT key will not work, because there will be no Alt key if both configured as AltGr.
    – user.dz
    Apr 12, 2014 at 7:30
  • 1
    @user.dz One would of course want that in order to continue using Left Alt as a modifier for writing symbols like @, |, «. or ». I don't want to have to relearn to use the Right Alt key for that.
    – slhck
    Jun 5, 2018 at 19:56
  • try this answer here("askubuntu.com/questions/24916/…)
    – obake
    Jun 11, 2018 at 13:12
  • this depends on your keyboard layout. I experienced this problem because I was using Italian/European Keyboard Layout. If you switch to US layout, alt gr is replaced with alt key Feb 25, 2020 at 7:03

6 Answers 6

7
+50

Swapping Left ALT & Right ALT functions

  1. The following command will set:

    • Left ALT as level3-switch or ALT Gr
    • Right ALT as normal-alt or ALT

    _

    gsettings set org.gnome.desktop.input-sources xkb-options "['lv3:lalt_switch','lv3:ralt-alt']"

    Effective immediately.

  2. To reset it:

    gsettings reset org.gnome.desktop.input-sources xkb-options

    or gsettings set org.gnome.desktop.input-sources xkb-options "[]"

Notes:

  • To see all available options for all modifier keys make a look on /usr/share/X11/xkb/rules/xorg.lst
  • There are other hacks, I don't recommend. Like changing line include "level3(ralt_switch)" or swapping key codes in X11/xkb layout files.
4
  • 1
    When I do that, the Right Alt key works the same as the Left Alt one (i.e., I cannot Alt-Tab anymore, or keyboard shortcuts that require Alt do not work).
    – slhck
    Jun 6, 2018 at 14:31
  • @slhck Yes, by default making a key as layout level switch will disable it from modifier setup. Otherwise, you get a weird actions, lalt+a will activate menu and insert a with accent. :/. AFAIK xkb does not support multiple actions for short and long press.
    – user.dz
    Jun 6, 2018 at 15:12
  • @slhck the original answer is exactly asking for that: "My questions are how can I get the current mapping of the right Alt key and assign it to the left Alt key?" If you have a different question, please a new question.
    – danzel
    Jun 11, 2018 at 22:33
  • 1
    @danzel I understand there is a slight difference between simply mapping Right Alt to Left Alt, but you still need the functionality of Left Alt available somewhere in order to properly use the OS. With the given constraints I guess that this answer is the best one.
    – slhck
    Jun 12, 2018 at 7:17
2

First, select System Settings :

Screenshot 1: open System Settings

Select Keyboard Layout from the presented window :

Screenshot 2: select "Keyboard Layout"

You will be presented with a list of all available layouts. Just press the Options button:

Screenshot 3: click "Options"

Lastly, from the presented list select Alt/Win key behavior and modify to your needs:

Screenshot 4: "Alt/Win key behavior" list

3
  • 1
    This is nice but it doesn't solve my issue.
    – konze
    Apr 12, 2014 at 11:13
  • Sorry to hear that. Perhaps a look at this link will be more helpful.
    – hmayag
    Apr 12, 2014 at 20:54
  • I came back to this (unfortunately unsolved) issue, now I placed a bounty on the question. Unfortunately the options you showed do not include a control for swapping Left and Right Alt.
    – slhck
    Jun 5, 2018 at 19:59
2

Ubuntu 18:04

gnome tweaks -> Keyboard & Mouse -> Additional Layout Options -> Key to choose the 3rd level -> Any Alt

enter image description here

1

I know this question is old, but I found the answer fot it!

You simply have to open gnome tweaks -> Keyboard & Mouse -> Additional Layout Options -> Key to choose the 3rd level -> Right Alt never chooses 3rd level and your right alt works the same way left alt does.

If you really want a 3rd grade button you still can choose any other option like right win or menu button for example.

I personally like to use the menu button as my alt grade and it makes much more sense since I don't use this button.

0

Right Alt is often used as the Compose Key so it may have been mapped to that function. You might solve your problem by looking closely in your system settings, under Hardware > Keyboard (not Personal > Keyboard Layout). Under the shortcuts tab, check and see if Right Alt is used as a shortcut to anything. Here's an example of what that menu looks like on my system, where I've mapped it as the Compose Key.

enter image description here

4
  • Did that solve your issue, @slhck ?
    – JR.
    Jun 11, 2018 at 21:21
  • Unfortunately not. I have Caps Lock set as my compose key. I do not even know how to get to this window that you're showing.
    – slhck
    Jun 12, 2018 at 7:18
  • Perhaps it's a little different in 12.04 than it is on my 14.04 machine. It's the option in the upper right of the first image on this page: techdrivein.com/2012/03/ubuntu-1204-features-new-easily.html
    – JR.
    Jun 12, 2018 at 18:41
  • I am using 18.04 now so that's why, I guess!
    – slhck
    Jun 13, 2018 at 6:16
0

I used the process described in this answer, but instead of "Alt/Win key behavior", I found "Keys Level 3" and checked "Every key alt"

enter image description here

(My Linux is in French, sorry for my poor translation)

You must log in to answer this question.

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