• 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
catching modifier keys in a keydown event
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

catching modifier keys in a keydown event


  • Subject: catching modifier keys in a keydown event
  • From: Travis Siegel <email@hidden>
  • Date: Fri, 30 Jun 2006 20:45:13 -0400

Hello all.
I'm having trouble figuring out how to catch modifier keys (command/ option/shift/whatever)
My keydown event is like this:
- (BOOL) onKeyDown: (NSEvent *)theEvent
{
NSString *keyString = [theEvent characters];
unichar key = [keyString characterAtIndex:0];
BOOL keyIsHandled = YES;
OSStatus result = noErr;


	switch (key) {
		case NSUpArrowFunctionKey:
break;
		case NSDownArrowFunctionKey:
	break;
		case NSCarriageReturnCharacter:
		case NSEnterCharacter:
			break;
		case ' ':
			break;
		case 'A':
		break;
		case 'E':
break;

default:
keyIsHandled = NO;
break;
}
NSAssert1 (!result, @"key handled was %d", result);
return keyIsHandled;
}
}
I have no trouble getting regular keypresses, and even the function keys that have values.
But what I can't figure out is how to pickup a key like command-L, or something more complex command-option-L.
I know these keys are returned, and there's four bytes in the key event string, but I have no idea how to interpret these codes.
Do I need another function to handle those keys, or is there some kind of ns values like there is for the arrow keys I can use?
If anyone has some help on this, I'd be forever greatful.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: catching modifier keys in a keydown event
      • From: Shawn Erickson <email@hidden>
  • Prev by Date: Re: Preference Pane name?
  • Next by Date: NSLog() and stderr
  • Previous by thread: Re: Preference Pane name?
  • Next by thread: Re: catching modifier keys in a keydown event
  • Index(es):
    • Date
    • Thread