macOS App: handling key combinations bound to global keyboard shortcuts

前端 未结 3 580
长发绾君心
长发绾君心 2021-02-04 15:02

In some apps, it makes sense for the app to directly handle keyboard shortcuts which are otherwise bound to system wide combinations. For example, ⌘-Space (normally Spotlight) o

3条回答
  •  无人共我
    2021-02-04 15:15

    I solved this ages ago but I only just noticed I never posted it here. The answer ended up involving CGSSetGlobalHotKeyOperatingMode(). This is not a public API, but there are a number of Mac App Store apps which use it by obfuscating the function name and looking it up dynamically. Apple doesn't seem to mind. The API is pretty straightforward to use, and there's plenty of open example source code floating about.

提交回复
热议问题