• 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
How to handle non-character keyboard events?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to handle non-character keyboard events?


  • Subject: How to handle non-character keyboard events?
  • From: André Benassi <email@hidden>
  • Date: Fri, 7 Dec 2001 09:51:38 -0600

I am trying to get my small program to recognize arrow key inputs from
the keyboard. I have the following method (kiped from Mike Beam's
wonderful article on O'Reilly):

- (void)keyDown:(NSEvent *)theEvent {
NSString *keyChar = [theEvent characters];

if ( [keyChar isEqualToString:@"c"] ) {
[path removeAllPoints];
[self setNeedsDisplay:YES];
}
}

- (BOOL)acceptsFirstResponder {
return YES;
}

I am trying to modify the code so it handles the Up arrow key,
NSUpArrowFunctionKey. I have tried replacing

[keyChar isEqualToString:@"c"]

with:

[keyChar isEqualToString:NSUpArrowFunctionKey]
[keyChar isEqual:NSUpArrowFunctionKey]
and:

NSString *theKey = NSUpArrowFunctionKey;
[keyChar isEqualToString:theKey]

3 questions:

Am I going about this the right way?
NSUpArrowFunctionKey is a (Unicode) unsigned short. How do I cast it to
a string? Do I need to?

Any help very appreciated from this newbie.

Andri Benassi
http://www.visi.com/~andre/


  • Follow-Ups:
    • Re: How to handle non-character keyboard events?
      • From: Stéphane Sudre <email@hidden>
    • Re: How to handle non-character keyboard events?
      • From: Alexandre Aybes <email@hidden>
  • Prev by Date: Re: How to check if 'mysqld' is running?
  • Next by Date: Re: How to handle non-character keyboard events?
  • Previous by thread: Re: How to check if 'mysqld' is running?
  • Next by thread: Re: How to handle non-character keyboard events?
  • Index(es):
    • Date
    • Thread