I’m hacking on a simple Cocoa app to make blocks move around the screen like a video game. I need to detect key presses, but I’m not going to have text entry fields like a dialog box would have.
How do I get key presses without text controls? In particular, I need to get arrow keys.
In your game view, define the keyUp and keyDown methods:
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.