Catching keyboard events in a Cocoa app WebView
I have a Cocoa app开发者_JAVA百科 that embeds a WebView. I'd like to intercept a keyboard shortcut so that I may perform an action in the WebView.
I do not want to implement a menu item for this action. In fact, ideally I only want this shortcut to apply when the user is in a textarea box in the WebView.
How do I catch the keyboard shortcut so that I can pass it on to my WebView?
You can either have something higher up in the responder chain handle it first or use a CGEventTap if that doesn't cut it.
精彩评论