• 2013-04-06

    How to capture ESC key in a Cocoa application?

    Views: 21605 | No Comments

    You may want to capture(or intercept, detect) the ESC key press in a Cocoa application, capture the ESC key down in Application scope for the whole app, or just in Window scope for some certain windows.

    The NSApplicationDelegate is not a subclass of NSResponder, so you can not implement the keyDown: method int app delegate. The NSWindowController is a subclass of NSResponder, you may implement keyDown: method in it, but it will not get invoked when user press the ESC key(with exceptions) and not when user is typing in a text input.

    The solution is to use a Event Monitor.

    Continue reading »

    Posted by ideawu at 2013-04-06 17:02:56 Tags:
|<<<1>>>| 1/1 Pages, 1 Results.