Re: Turning Keyboard Repeat Off in a Game
Re: Turning Keyboard Repeat Off in a Game
- Subject: Re: Turning Keyboard Repeat Off in a Game
- From: Angela Brett <email@hidden>
- Date: Wed, 19 Mar 2003 22:51:42 +1200
Is there a way to turn off/bypass key repeat while the
game is running (for the sake of efficiency), so only
one keyDown method occurs each time a key is held
down? I've seen some strange code snippet in the
Omnigroup porting presentation, but I can't figure out
what's going on.
You could check if the key event is a repeat by using NSEvent's
-isARepeat method, and ignore it if it is a repeat.
If you actually want repeats for the game (say for moving a player
along), but you don't want the timing to be dependent on the key
repeat rate, you could keep track of which keys are down using keyUp:
and keyDown: and have a timer or timers which go through the keys
currently down and do whatever is supposed to happen when those keys
are held down. That's roughly what I did in Brettrix - I'll share the
source if you like, since all the key processing is in a separate
(super)class from the other game-specific view stuff.
--
Angela Brett
Email: email@hidden
Editor,
http://OldScientist.com
Cocoa development:
http://cocoa.co.nz
Homepage:
http://acronyms.co.nz/angela
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.