In your game view, define the keyUp and keyDown methods:
@interface MyView : NSView
-(void)keyUp:(NSEvent*)event;
-(void)keyDown:(NSEvent*)event;
@end
@implementation MyView
-(void)keyUp:(NSEvent*)event
{
NSLog(@"Key released: %@", event);
}
-(void)keyDown:(NSEvent*)event
{
// I added these based on the addition to your question :)
switch( [event keyCode] ) {
case 126: // up arrow
case 125: // down arrow
case 124: // right arrow
case 123: // left arrow
NSLog(@"Arrow key pressed!");
break;
default:
NSLog(@"Key pressed: %@", event);
break;
}
}
@end
See the documentation for NSView and NSEvent for more info. Note that the keyDown and keyUp events are actually defined on NSResponder, the super class for NSView.