Results 1 to 2 of 2
  1. #1
    [cocoa keyboardInput]

    Member Since
    Nov 26, 2006
    Posts
    18
    [cocoa keyboardInput]
    I am stuck right now on how to capture the arrow keys.I could just use the key codes but the documentation says they are hardware specific.

    According to the docs.
    Note that some function keys are handled at a lower level and are never seen by your application...
    The Arrow keys are considered function keys from what I gather because,

    if ([anEvent modifierFlags] & NSFunctionKeyMask ) {
    }

    will ring TRUE when the arrow keys create an event. I could use a clue as to how I can then test for the constants "NSUpArrowFunctionKey" and his partners?
    Every test I have tried so far ring TRUE.

  2. #2
    [cocoa keyboardInput]

    Member Since
    Nov 26, 2006
    Posts
    18
    Not to bump the post but:
    Just in case anyone is interested. I have found one way. You can load the StandardKeyBinding.dict dictionary file and check the key-value using the return from [anEvent characters] as the key.

    Code:
    - (void)keyDown:(NSEvent *)anEvent
    {
    	if ([anEvent modifierFlags] & NSFunctionKeyMask) {
    		if ([[keyBindings objectForKey:[anEvent characters]] isEqual:@"moveLeft:"]) {
    			NSLog(@"leftArrow"); 
    		}
    		if ([[keyBindings objectForKey:[anEvent characters]] isEqual:@"moveRight:"]) {
    			NSLog(@"rightArrow");
    		}
    		if ([[keyBindings objectForKey:[anEvent characters]] isEqual:@"moveDown:"]) {
    			NSLog(@"downArrow");
    		}
    		if ([[keyBindings objectForKey:[anEvent characters]] isEqual:@"moveUp:"]) {
    			NSLog(@"upArrow");
    		}
    	}
    }
    If anyone knows a better way, for that matter any other way, please let me know.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Any Cocoa Developers Out There?
    By matt9b in forum OS X - Development and Darwin
    Replies: 0
    Last Post: 05-11-2009, 06:08 AM
  2. Taking up Cocoa
    By scathe in forum OS X - Development and Darwin
    Replies: 1
    Last Post: 01-18-2009, 06:35 AM
  3. cocoa and pop3
    By jmndos in forum OS X - Development and Darwin
    Replies: 1
    Last Post: 10-03-2008, 04:07 AM
  4. Cocoa question
    By Osiris22x in forum OS X - Development and Darwin
    Replies: 1
    Last Post: 04-09-2007, 03:37 AM
  5. Cocoa/Xcode
    By dim in forum OS X - Development and Darwin
    Replies: 1
    Last Post: 10-20-2004, 11:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •