Created
September 3, 2014 22:40
-
-
Save elpsk/156bbd11d8fcd74fc190 to your computer and use it in GitHub Desktop.
MAC OSX - Keystroke listener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// listen for keystrokes | |
[NSEvent addGlobalMonitorForEventsMatchingMask:NSKeyDownMask handler:^(NSEvent *event) | |
{ | |
NSLog(@"%lui -- %@", (unsigned long)[event modifierFlags], event.characters ); | |
// | |
// if flag and char do something, like bring to front the application | |
// 256 is ESC, in my case. | |
// | |
if ( [event modifierFlags] == 256 && [[event charactersIgnoringModifiers] compare:@""] == 0 ) | |
{ | |
NSLog(@"-------- IN --------"); | |
[NSApp activateIgnoringOtherApps:YES]; | |
} | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment