Search code examples
x11xlib

X sends many key up events when a key is held


If I hold a key, I get sent many 'key down' events for that key, annoying but workable; the same approach that win32 api uses.

However, I also get sent a 'key up' event after each 'key down'. This means that if I hold a key I get sent:

key down
key up
key down
key up
...
key down
key up

This effectively means there is no way to differentiate between a key being held and a key being pressed really fast.

The event mask I am using for my window is FocusChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask | KeyPressMask | KeyReleaseMask | StructureNotifyMask

Is there some cryptic setting somewhere in X that will stop it from sending 'key up' events until the key is actually released. Do I need to 'grab' the keyboard or something first?


Solution

  • Here is the more definitive answer, right from these boards. First result on Google:

    Ignore auto repeat in X11 applications