Another approach is to use
xmodmap. Add the following to your
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
- 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:
KeyPress event for
KeyRelease event for
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
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.