Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Gandolfmatt

macrumors member
Original poster
Jul 18, 2008
46
0
I'm currently playing with OpenGl in the cocoa framework of Xcode and I'm trying to get my app to detect if a arrow key is pressed. I've researched for hours today with hardly any luck, I have found other examples that worked and tried to duplicate their code into my project, but when I press a arrow key the computer beeps and nothing happens.

Anyone know a solution or could give me instructions of how to do it?


-Gandolf
 
I'm currently playing with OpenGl in the cocoa framework of Xcode and I'm trying to get my app to detect if a arrow key is pressed. I've researched for hours today with hardly any luck, I have found other examples that worked and tried to duplicate their code into my project, but when I press a arrow key the computer beeps and nothing happens.

Anyone know a solution or could give me instructions of how to do it?


-Gandolf

Doesn't something like this work?

Code:
-(void)keyDown:(NSEvent *)theEvent{
 printf("You pressed a key. Thank you, try again.");
}

Also, is your view configured to be firstresponder? Because if something else responds to the keydown before it gets to your code, you won't see the event.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.