[Q] Keyboard repeats stop when I hit another key. How do I get them back?
[Q] Keyboard repeats stop when I hit another key. How do I get them back?
- Subject: [Q] Keyboard repeats stop when I hit another key. How do I get them back?
- From: Alexandre Aybes <email@hidden>
- Date: Mon, 5 Nov 2001 22:58:26 +0100
I am reposting this mail to some better lists (orignally posted
on mac-opengl)... :)
Hi there,
In my continuing struggle to write some cool game for Mac OS X
using this wonderful Cocoa framework I am facing another problem
with keyboard events.
I am using a full screen rendering context (that I got to work)
and I am pooling for the events [NSApp nextEventMatchingMask:...
blablabla]; my current problem is that when I get the key
repeats (for example the user holds the up arrow) I move
correctly, but as soon as I hit another key (let's say space to
jump/fire/whatever) the arrow key repeats stop, and therefore my
character doesn't move anymore :-/
Here is what I do (please let me know if it is
good/correct/bad/THE thing NOT to do :)
I wanna get the events as fast as possible to be as responsive
as possible, therefore I use some code I found in the Omni
examples (the InputExample from the GDC 2001) to set the key
repeat threshold and the key repeat interval to 0. This might be
a bit brutal, but I couldn't figure out how to get the key
repeats fast enough otherwise. Maybe there is a way to get the
keyboard's state directly which might be even faster... if so
please tell me :)
Thanks a lot!
Alex.