Skip to content

Instantly share code, notes, and snippets.

@smokris
Created October 16, 2017 14:34
Show Gist options
  • Save smokris/609d59ad20415e5159efbd08351e7f4a to your computer and use it in GitHub Desktop.
Save smokris/609d59ad20415e5159efbd08351e7f4a to your computer and use it in GitHub Desktop.
[NSEvent addLocalMonitorForEventsMatchingMask:NSKeyDownMask handler:^(NSEvent *event) {
// Cmd+Shift+O (Open Most Recent File)
if ((event.modifierFlags & NSCommandKeyMask)
&& (event.modifierFlags & NSShiftKeyMask)
&& (event.keyCode == kVK_ANSI_O))
{
editor->openMostRecentFile();
return (NSEvent *)nil; // event was handled by this monitor (avoids the system beep)
}
// Cmd+Option+O (Open Random Example)
else if ((event.modifierFlags & NSCommandKeyMask)
&& (event.modifierFlags & NSAlternateKeyMask)
&& (event.keyCode == kVK_ANSI_O))
{
editor->openRandomExample();
return (NSEvent *)nil; // event was handled by this monitor (avoids the system beep)
}
// event was not handled by this monitor; pass it on.
return event;
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment