• 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
Detecting the Enter Key
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Detecting the Enter Key


  • Subject: Detecting the Enter Key
  • From: Eric Gorr <email@hidden>
  • Date: Wed, 10 Dec 2008 12:43:06 -0500

One way to check to see if the enter key has been pressed is to:

[theEvent keyCode] == 0x04C

where 0x04C is the keyCode corresponding to the enter key.
(Is there an Apple defined constant for this key code?)



Another way, found at:

http://developer.apple.com/samplecode/TrackBall/listing9.html

is to do:

NSString *characters = [theEvent characters];

switch ([characters characterAtIndex:0])
{
    case NSEnterCharacter:
    case NSNewlineCharacter:
    case NSCarriageReturnCharacter:
}



My question is which method is the preferred or recommended way to detect this key in onKeyDown?

Is there a better way?

Thank you.





_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Detecting the Enter Key
      • From: "Michael Ash" <email@hidden>
    • Re: Detecting the Enter Key
      • From: Benjamin Dobson <email@hidden>
    • Re: Detecting the Enter Key
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Re: How Can I Notify DrawRect Method?
  • Next by Date: Re: Detecting the Enter Key
  • Previous by thread: Re: NSOutlineView problem with Text cells.
  • Next by thread: Re: Detecting the Enter Key
  • Index(es):
    • Date
    • Thread