When creating shortcuts, the left and right Alt keys map to identical references.

Is there a way to create a shortcut for both individually so that RAlt+Key1 and LAlt+Key1 can point to different behaviors?

Output from showkey:

press any key (program terminates 10s after last keypress)...
keycode  28 release
keycode  56 press    <-- Left ALT key
keycode  56 release
keycode 100 press    <-- Right ALT key
keycode 100 release
keycode  29 press
^Ccaught signal 2, cleaning up...

Server: X11


enter image description here

  • Are you sure you mean Alt (and not ctrl) ? If yes then please provide some info about your keyboard. Those I kwow having only one alt key at the immediate left of the spacebar, the one at the immediate right of the leyboard being labeled alt gr and does not serve the same purpose than the alt key.
    – MC68020
    Commented Feb 10 at 22:51
  • I have an external Nuphy keyboard conencted to a Dell Precision. Both have the right key to the spacebar labeled as Alt NOT AltGr. Pressing either the left alt or right alt of both devices leads to the same result in KDE
    – wasp256
    Commented Feb 10 at 22:54
  • Could you log on console and use the showkey command, then hit your left-Alt-key and then hit your right-alt key. In case the number printed are different and there must be a solution either they are identical and then you cannot expect what you want.
    – MC68020
    Commented Feb 10 at 22:57
  • Updated with the output
    – wasp256
    Commented Feb 10 at 23:13
  • Great ! We'll manage. Could you additionally tell if you are using X11 or Wayland as the backend and also what is your selected keyboard layout ? (system settings / Input Devices / Keyboard / Layouts )?
    – MC68020
    Commented Feb 11 at 11:19

1 Answer 1


Disclaimer A : KDE-Plasma offers very limited possibilities to remap keyboard keys. At most, with regards to compose keys, swapping Left or Right Alt with whatever Ctrl or meta keys or accessing >2 levels.
These are made available following System-Settings > Input Devices > Keyboard > Advanced page after having marked the Configure options check box

In order to enable far much more, what I suggest (and successfully tested under my KDE-Plasma-5.25.5, but that should work irrespective of the desktop, provided X11 (incidentally evdev) is used as backend), consists in hacking the xkb map in order to swap keycodes <-> symbols association.

Disclaimer B : While this answer does actually address your question as worded in the title, it is not likely to help you (as suggested in your question (using whatever-alt +key )) mapping L or R alt key to any other key than any valid compose-key that are ctrl, alt, shift and meta.
Consequently, if what you actually want is mapping (L-or-R)_ALT key to whatever compose key then goto Disclaimer A; else contin :

1/ Dump your current keyboard configuration

Achieve this by simply firing (cwd being whatever user writable directory) xkbcomp -xkb $DISPLAY xkbmap from Konsole or whatever DE's favorite xterm.

2/ Edit that xkbmap file in order to make appropriate changes (assuming R_ALT is the one to be changed, in case of whatever else... only... adapt to whatever else.)

2.1 : Locate the line specifying <RALT> = specifying in regard the keycode to be associated to the right Alt key (was initially set to 108 in my particular case)

2.2 : Jump to... whatever else desired symbolic association.
Whatever... well... not exactly whatever ;-) since your DE is not likely to accept whatever key for shortcuts definition. (KDE in particular does not)
Some keycode of some elsewhere unused (but existing) keyboard key could well fit for purpose but who can tell what you (or the DE) will want to assign to this key in the future ?
Ideally, what I suggest (and successfully experimented), is to find some already defined BUT not physically existing function key (so that it can in no way be activated)
This being, in my configuration the case of the... 13th function key that does not physically exist on my keyboard but being actually associated as to some keycode, (was 191 in my case) =>
Simply swap these values, e.g. what I did on my system, change :

<RALT> = 108 
<FK13> = 191


<RALT> = 191 
<FK13> = 108

This instructing evdev to understand keycode 108 as associated to the 13th function key instead of the Right Alt key. (Of course, since the 13th function key does not really exists reassigning original RALT assignment is only for the sole sake of... aesthetics... :-)
Now save and quit.

3/ Replace the map (enforce the new configuration)

Simply fire xkbcomp -w 0 xkbmap $DISPLAY and test !
In your precise case, assigning some shortcut via KDE-Plasma System Settings > Shortcuts which should now accepted the Right Alt key referring to whatever BUT the ALT key.
Of course, it wont't be composable, cf Disclaimer B.

4/ Enforce this remapping across reboots

I do not (here&now) develop this important paragraph (dedicated to the integration with the Plasma DE.) because I'm not sure that this answer will satisfy OP's needs.
Do not hesitate to have your say in comments, I WILCO !

You must log in to answer this question.

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