Re: How to handle non-character keyboard events?
Re: How to handle non-character keyboard events?
- Subject: Re: How to handle non-character keyboard events?
- From: Alexandre Aybes <email@hidden>
- Date: Fri, 7 Dec 2001 17:10:52 +0100
This is what I am using (taken pretty much straight out of the
OmniGroup Game examples):
- (void)keyDown:(NSEvent *)theEvent
{
NSString *characters;
unichar c;
unsigned int characterIndex, characterCount;
// There could be multiple characters in the event.
characters = [theEvent charactersIgnoringModifiers];
characterCount = [characters length];
for (characterIndex = 0; characterIndex < characterCount;
characterIndex++)
{
c = [characters characterAtIndex: characterIndex];
switch(c)
{
case NSUpArrowFunctionKey:
if (isRunning)
[camera moveByDistance:keyboardSpeed*2.0];
else
[camera moveByDistance:keyboardSpeed];
break;
// [snip]...
}
}
}
Hope this helps,
Alex.