[xmonad] Capturing modkey release

Brandon Allbery allbery.b at gmail.com
Mon Jul 2 16:32:30 CEST 2012

On Mon, Jul 2, 2012 at 7:17 AM, Matthew Hague <matthewhague at zoho.com> wrote:

> Is there a way to capture a release of the modkey using e.g. the event
> hooks?
> I've tried modifying the source for debugkeyevents:
> http://xmonad.org/xmonad-docs/xmonad-contrib/XMonad-Hooks-DebugKeyEvents.html
> but this only captures the release of "proper" keys, not the modifiers.
>  (E.g.
> pressing mod+j will generate a press and release of the j key (with
> information about it's modifiers), but not the press and release of the
> modkey).

This is because there are no grabs established on the bare modifiers, nor
is there a generic "send all key events" mask in place, so X11 doesn't
bother to send events for them.  If it sent an event for every little thing
that happened, unsolicited, most programs would be busy-looping on noise
events instead of doing useful work; as such, you should always remember to
*request* the events you want.

So in this case you probably want to use grabKey (aka XGrabKey()) to select
for interest in the modifier key by itself; the handleEventHook handler
should ungrab the keyboard (you don't *really* want xmonad to seize
ownership of the keyboard every time you touch the key), do whatever you
want to do, and pass the event on.

(This is largely what the other suggestion does, once you poke at the code.)

brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/xmonad/attachments/20120702/74f2aa6d/attachment.htm>

More information about the xmonad mailing list