2

I would like to map the AltGr key on my keyboard to produce Ctrl+Alt. I am aware of xkb and xmodmap. As far as I could tell, however, using those you can only map from key combinations onto single keys, not the other way round.

hg8
  • 13,462
wehnsdaefflae
  • 121
  • 1
  • 5
  • You can also access the single-key alternatives for AltGr using the GUI -- to to settings-->Keyboard-->Shortcuts-->Typing-->Alternative Characters Key -- this will give you a drop down with several options. None of them are ctrl+alt, but I figure that it might be useful to others reading this thread. – MattKelly Apr 03 '17 at 12:37
  • btw: how in the high heavens is this a duplicate of the linked question? i swaer to god, sometimes i feel like they don'T even read the question. – wehnsdaefflae Dec 02 '22 at 12:05

1 Answers1

1

After trying and failing to get it to work with a combination of xbindkeys and xvkbd/xte (I could never get certain characters {, [, ], }, \, etc. to behave properly, perhaps because I use a Scandinavian keyboard layout), I finally found a simple and practical solution: Autokey. Here are the exact instructions to get it working:

  1. Install Autokey through Ubuntu Software (I used the GTK-version, not KDE) or by: sudo apt-get install autokey-gtk.
  2. Configure one script per key, e.g. for { use this code: keyboard.send_keys("<alt_gr>+7") and set the hotkey to Ctrl+Alt+7 (first set hotkey to 7 then add Ctrl and Alt as modifiers). This at least worked for the most important code-writing keys: { [ ] } \.
  3. Add autokey to Startup Applications (search for “start” to find it) and then add a program with “autokey” as the command.

This solution will work for anything running in the current X-session (I think) but will not work if you start a new terminal session using Ctrl+Alt+[F2-F6].

Zanna
  • 70,465