如何在Mac OS X中实现全局键盘挂钩? [英] How do you implement global keyboard hooks in Mac OS X?

查看:255
本文介绍了如何在Mac OS X中实现全局键盘挂钩?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这可以在Windows上完成,而XGrabKey可以用于X11,但是Mac OS X呢?我想创建一个类,该类允许设置即使在应用程序窗口处于非活动状态时也可以调用的快捷键.

I know this can be done for Windows and that XGrabKey can be used for X11, but what about Mac OS X? I want create a class that allows setting shortcut keys that can be invoked even when the application windows are inactive.

推荐答案

看看NSEventaddGlobalMonitorForEventsMatchingMask:handler:类方法.另外,您可能会发现快捷记录器很方便.

Take a look at addGlobalMonitorForEventsMatchingMask:handler: class methods of NSEvent. Also you may find Shortcut Recorder handy.

这篇关于如何在Mac OS X中实现全局键盘挂钩?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆