• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Turning Keyboard Repeat Off in a Game
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Follow-Ups:
    • Re: Turning Keyboard Repeat Off in a Game
      • From: Jamie Hodkinson <email@hidden>
References: 
 >Turning Keyboard Repeat Off in a Game (From: Jamie Hodkinson <email@hidden>)

  • Prev by Date: Jan Dev Docs
  • Next by Date: Window Sheet
  • Previous by thread: Turning Keyboard Repeat Off in a Game
  • Next by thread: Re: Turning Keyboard Repeat Off in a Game
  • Index(es):
    • Date
    • Thread