how do I observe keyboard input event while the applicaion is not actived

雨燕双飞 提交于 2019-12-08 07:42:39

问题


how do I observe keyboard input event while the applicaion is not actived.


回答1:


You'll need to create a CGEventTap using Quartz Event Services. The user must have access for assistive devices turned on, which makes sense, because that's the only legitimate reason for you to do that.

If you want to set up a hotkey, there's an API in Carbon Event Manager for that, and a Cocoa wrapper named SGHotKeysLib. Note that the Carbon Event Manager hotkey API is still supported in current, 64-bit Mac OS X.



来源:https://stackoverflow.com/questions/3546730/how-do-i-observe-keyboard-input-event-while-the-applicaion-is-not-actived

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!