[Kde-games-devel] keyboard delay on keyPressEvent
Burkhard Lehner
Burkhard.Lehner at gmx.de
Mon Feb 23 21:52:25 CET 2004
Hi Jan!
Am Montag, 23. Februar 2004 21:28 schrieb Jan Bernatik:
> I experience a delay when I hold a key. I get first keypress
> immediately, then like 1/2 sec delay, and then AutoRepeat events.
This is the normal function of the keyboard. You can adjust this delay in the
BIOS of your computer (i think). The AutoRepeat is not generated by Qt, but
by the keyboard itself. Just try it in any text editor you want: Press a key
and hold it. The letter is printed one time, and after some delay, autorepeat
is activated and the key repeats. As far as I know, there is no way to avoid
this delay between KeyPress and AutoRepeat. (You can adjust this delay in the
control center in KDE, but it is difficult or impossible to do this from your
application.)
> I didn't find in keyPressEvent docs any information what cause this
> delay. Can anybody push me in the good direction ? I searched archives
> on trolltech, but there are just AutoRepeat ignoring threads and nothing
> about this delay.
Why do you want to avoid this delay? If you want to, you can "simulate" your
own AutoRepeat:
Whenever a KeyPressEvent happens, start a timer, that fires regularly, and
connect a slot to its signal, that performes the AutoRepeat. (A typical time
for the timer would be around 20 ms.) When the corresponding KeyReleaseEvent
comes in, stop the timer, so that the AutoRepeat slot isn't activated any
more.
Keep in mind that you have to ignore the KeyPressEvents, that are triggered by
the keyboards autorepeat. (Otherwise you would have hundreds of timers
running! :-))
Hope this helps. Bye,
Burkhard
--
Burkhard Lehner (0631) 1 03 63
Walter-Flex-Straße 20 Burkhard.Lehner at gmx.de
67663 Kaiserslautern http://www.burkhardlehner.de
More information about the kde-games-devel
mailing list