[ Return to Bugs & Features | Roadmap 1.1 ]
|Status:||2 - Closed w/o Resolution|
|Priority:||2 - Low, e.g. a documentation error or undocumented side-effect|
|Scope:||3 - Applies to all machines and operating systems|
|Summary:||Unexpected FL_KEYUP events appear when a key is pressed for a long time|
Trouble Report Files:
Trouble Report Comments:
09:26 Feb 25, 2007
|When I hold down a key for some seconds, a series of FL_KEYDOWN events are produced. The bug is that among all those FL_KEYDOWN, at some time appears an isolated FL_KEYUP event or more. The time and rate of FL_KEYUPs is not constant, but after ~ 300 events, there has been normally one. |
Try the example. You can see the problem if it appears something like this:
To have a bit more of fun while you test the bug, try the synthesizer "zynaddsubfx": select an instrument which sounds interesting, and hold a key (with the keyboard on your computer) for some seconds. It restarts randomly. However, with a mouse click on the key, the sound is stable.
fltk 1.1.7 on Debian; g++ 4.1.2
13:30 Feb 27, 2007
|To quote the source code of the keyboard event handling system: |
// Stupid X sends fake key-up events when a repeating key is held
// down, probably due to some back compatability problem. Fortunately
// we can detect this because the repeating KeyPress event is in
// the queue, get it and execute it instead:
Well, in some cases, the KeyPress event is not in the queue yet, so a few KeyUp's slip through the net. This is a problem of the implementation of X Servers.
I have to suggestions for fixes on your side. They are to specific to fix in FLTK:
1: try calling Fl::key_state() whenever you get a FL_KEY_UP event. The state may still show the key as pressed
or 2: whenever you receive a FL_KEY_UP, set a very short timeout, then wait if you get another FL_KEY_DOWN on the same key. It should come pretty much immediatly, so calling Fl::check() may already be enough.
[ Return to Bugs & Features ]