Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Register Hotkey

How would I register a global hotkey in Objective-C/Cocoa (Mac) ?

For example, the hotkey I'd like to register would be Alt - Cmd - D

Any help would be appreciated!

like image 934
Seb Jachec Avatar asked Jan 26 '11 16:01

Seb Jachec


1 Answers

There's a convenient Cocoa wrapper for the required Carbon functions on GitHub: JFHotkeyManager. You could also use the new (since 10.6) NSEvent API addGlobalMonitorForEventsMatchingMask:handler:, but it only gets key events if access for assistive devices is enabled.

like image 170
omz Avatar answered Nov 03 '22 02:11

omz