Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to capture global key presses in Mac OS using Swift

Tags:

macos

swift

Is there any way to capture global key presses (even when my application isn't active) in Mac OS using Swift?

Thanks in advance.

like image 925
FrozenHeart Avatar asked Oct 31 '22 07:10

FrozenHeart


1 Answers

Yes, you can use NSEvent to add a global event monitor. Checkout this Swift 3 example here: https://stackoverflow.com/a/40509620/1791525

like image 185
Daniel Sposito Avatar answered Nov 15 '22 05:11

Daniel Sposito