On my laptop, I use the Win as a modifier. With the Fn key pressed, the key sends a different keysym and I use that as a Compose key.

keycode 133 = Hyper_L
keycode 134 = Multi_key
add mod4 = Hyper_L

I have some window manager key bindings of the form Hyper+KP_N. On a laptop, this requires pressing and holding Win, then pressing and holding Fn, then pressing KP_N and finally releasing everything. If I press Fn before Hyper, this sends the Multi_key keysym instead of Hyper_L, so I'm pressing Compose. I find the finger coordination required to press Fn before Hyper to be a lot less, so I'd like to be able to do that. If I then press a keypad key (which requires Fn), I want the key press to be interpreted as the mod4 modifier instead of Multi_key.

I can add the mod4 modifier to the Multi_key keysym, and this makes my window manager bindings work when I press Fn and Hyper in either order. However, if I press Fn first (which is how it happens naturally), this records a Multi_key keysym, so a key sequence like Fn+Hyper+KP_1, a, ' ends up switching to workspace 1 and inserting á instead of 'a, because the application that is focused after the keyboard shortcut activates receives a key release event for Multi_key.

How can I have my cake and eat it?

  • If I press Hyper and Fn in either order, then press a keypad key, this should only trigger my window manager binding and not leave a pending Compose. Either the application should not receive a key release event for Multi_key, or it should receive another event (injected by the window manager) that will effectively cancel the first one.
  • If I press and hold Fn and press Hyper, then release them both, this should send a press and release event for Multi_key.

I don't mind whether this is done through a change of my keyboard configuration, or of my window manager bindings, or both. The window manager is sawfish, so it's pretty flexible.

If the solution involves XKB, I don't want to define my whole keyboard configuration through XKB. The XKB part should focus on defining a group for the affected keys (or whatever it takes).

  • Have a look at my answer here. You might be able to use xbindkeys for this. – terdon Sep 25 '13 at 14:53
  • @terdon I don't see how this helps. Executing something after a key press isn't my problem — my window manager can do this just as well. – Gilles 'SO- stop being evil' Sep 25 '13 at 20:10
  • I was thinking that if you set up your shortcuts through xbindkeys you might be able to get consistent behavior irrespective of the order in which they were pressed. No idea if this would work but it might be worth a shot. – terdon Sep 25 '13 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.