Re: Detecting the Enter Key
Re: Detecting the Enter Key
- Subject: Re: Detecting the Enter Key
- From: Ken Thomases <email@hidden>
- Date: Wed, 10 Dec 2008 11:48:32 -0600
On Dec 10, 2008, at 11:43 AM, Eric Gorr wrote:
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?)
kVK_ANSI_KeypadEnter
but it's only defined in a Carbon header (Events.h in the HIToolbox
sub-framework).
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?
Given that you found that in Apple-written sample code, I'd say that's
what they recommend. ;)
Cheers,
Ken
_______________________________________________
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