On Sep 29, 2011, at 8:42 AM, Nick wrote: > how can I get a keydown (and keyup) events in an NSDocument-oriented > application for a particular document's window? > I'd like to get a control activated/deactivated on the window, depending on > whether the specific key is pressed or released.
Key events are passed along the responder chain. The document window delegate is in the responder chain and will respond to -keyDown:, -keyUp:, and -flagsChanged: events. You could subclass NSWindowController and make it the delegate of your document window and handle the events there. NSWindowController Class Reference documentation has a nice paragraph on subclassing. http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindowController_Class/Reference/Reference.html Document-Based Applications Overview documentation also has a section on "Should I subclass NSWindowController?" http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Documents/Tasks/FAQ.html#//apple_ref/doc/uid/20000954-1080900 If you need custom handling of modifier keys at the application level or absolutely need all key up events you could subclass NSApplication and override the -sendEvent: method. --Richard _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com