• 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: Detecting Keydowns
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting Keydowns


  • Subject: Re: Detecting Keydowns
  • From: Stéphane Sudre <email@hidden>
  • Date: Wed, 13 Jun 2001 19:27:38 +0200

On mardi, juin 12, 2001, at 03:58 PM, Eric Peyton wrote:

If you are in a hard loop (i.e. you aren't using timers to fire the next iteration, you are in a while (1), etc.) you can usually use the nextEvent (nextEventMatchingMask:) methods on NSApplication to get and deploy (postEvent: or sendEvent:) the next event on the stack. Then you can just register your view to accept key down events and when you get a keyDown: check the event's modifier flags to see if Cmd is being pressed and if the key down character was '.'.

Read up on NSApplication and NSEvent.

I can give you a better example if you need code, but this is the method I have used in the past.

What if you just want to detect if the option, control keys are down at one moment ?

I believe it's possible to get this information using Carbon and the GetKeys stuff. But is there a Cocoa way to do that ?


References: 
 >Re: Detecting Keydowns (From: Eric Peyton <email@hidden>)

  • Prev by Date: Rearranging tabs in NSTabView
  • Next by Date: Re: Subclassing NSTextView and characters with diacritical marks
  • Previous by thread: Re: Detecting Keydowns
  • Next by thread: Re: Detecting Keydowns
  • Index(es):
    • Date
    • Thread