Another approach is to use xmodmap
. Add the following to your ~/.Xmodmap
:
keycode 134 = ISO_Level3_Shift Multi_key
This is case sensitive. The right alt key ( AltGr ) on my keyboard happens to have keycode 134. If this doesn't work, the likely explanation is that your keyboard uses a different number for that key. To find out, run xev
, hit whatever key you want to use and look for the part that says "keycode XXX".
You can of course use any key for the purpose; for instance,
keycode 38 = a Multi_key
would make the a key serve as the compose key (only) when shifted. The inability to type capital As would be a clear detriment, so perhaps you want to do something else ☺
I use Shift+Shift with a trick:
keysym Shift_L = Shift_L Multi_key
keysym Shift_R = Shift_R Multi_key
This makes the left shift key act as the left shift key and the right shift key as the right shift key—except that if you hold a shift key, each shift key acts like Compose. A few scenarios to illustrate:
If you press left shift, press right shift, release right shift, and release left shift—then you get the same effect as if you had pressed a physical Compose key (old Sun keyboards had those, IIRC). So in particular:
- ShiftShift + : + ) produces a smiley, ☺ (at least with my
~/.XCompose
)
- ShiftShift + a + a produces the å character, "å".
If press left shift, press right shift, and then release the two shift keys in the opposite order, you get the same effect as above.
If you press left shift and release it again (with no intervening right shift), you get two keyboard events:
- a
KeyPress
event for Shift_L
- a
KeyRelease
event for Multi_key
This is because when you release the left shift key, a shift key is being held (the left one -_-) so the key is treated as if Multi_key
was all it ever did. This hasn't caused me any noticeable problems, but perhaps some old and buggy application could choke on the KeyPress
vs. KeyRelease
mismatch.
Note also that interaction between one-shot keys, modifier keys and state-toggle keys (e.g. a, Shift and Caps Lock) interact funnily. If you want to use the same key both as a Caps Lock key and (when shift is held) a compose key, you might get funky effects. I seem to recall that you get all applicable effects, which is probably not what you want, but feel free to try it out.
The question claims this doesn't work. Why is the answer accepted then? See also: http://unix.stackexchange.com/questions/265834/setxkbmap-option-lv3ralt-switch-multikey-doesnt-work-with-many-layouts
– Pavel Šimerda – 2016-02-25T20:20:55.283@PavelŠimerda answer and question are both by me, and while I use a different setup by now, I found it like that back then. I think it might be related to how
lv3:ralt_switch_multikey
is used actually. – blueyed – 2016-02-28T23:38:16.100+42 – wȯŕkß łīkə ả čhą®µ™ ;-) The best of it is that character shortcuts in my user-defined map are still working if I use
AltGr
+Shift
(fourth shift level) instead of the less commonShift
+AltGr
(now Compose), and thatsystemsettings
keeps it. – PointedEars – 2012-12-03T18:38:15.917You do not have to edit the configuration file. That setting is located in KDE 4.8.4 under “Keyboard” → “Advanced” → “Key for changing into the third keyboard level” → “Right Alt key, Shift + right Alt key is Multi key”. That is why it survives an update via the GUI. (I have translated the German labels, so the English ones may vary.) – PointedEars – 2013-01-27T11:00:52.633