0

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?

Lev Levitsky
  • 63,701
  • 20
  • 147
  • 175
thecoshman
  • 8,394
  • 8
  • 55
  • 77
  • Yes, there is a way to differentiate: look at the time stamp of each event. There is physical travel time for the key (and someone's finger) below which is the autokey stuff. – Bob Dalgleish Jul 07 '13 at 01:23
  • So you are saying I have check for all key up and key down events, store them into a buffer, and remove any keyup events that have a keydown with the same time stamp? Seems like a very poor solution to me. what about the final *true* keyup event? That will still have a matching keydown with the same time stamp, so how can I know this one is special and should be considered real – thecoshman Jul 07 '13 at 09:56
  • It's the auto repeat doing it, you can turn it off with `xset r off` but it will stop auto repeat for all programs – parkydr Jul 07 '13 at 16:38
  • well... not really a 'possible' dupe, it is is a dupe. I just didn't happen to phrase my question in such a way as to find that one. Thanks @BobDalgleish – thecoshman Jul 07 '13 at 22:10

1 Answers1

3

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

Ignore auto repeat in X11 applications

Community
  • 1
  • 1
Bob Dalgleish
  • 8,167
  • 4
  • 32
  • 42