I am programming an application that will be a basic video game, but the keyUp: (NSEvent) and keyDown: (NSEvent) methods are not executed.
This is my code:
-(void)keyUp:(NSEvent*)event {
NSLog(@"Key %@", event);
}
-(void)keyDown:(NSEvent*)event {
switch( [event keyCode] ) {
case 126:
case 125:
case 124:
case 123:
NSLog(@"Arrow key pressed!");
break;
default:
NSLog(@"Key %@", event);
break;
}
}
I made sure that it was in a subclass of NSResponder (although it is in NSOpenGLView, can this affect it?), And the other is that I do not see any problems. Any help is very helpful. Thank:)
source
share