[NSEvent addGlobalMonitorForEventsMatchingMask:NSFlagsChangedMask
handler:^(NSEvent *event){
// CMD
if ([event keyCode] == 55)
{
if ([event modifierFlags] == 1048840)
{
NSLog(@"CMD hold");
}
else
{
NSLog(@"CMD release");
}
}
// ALT
if ([event keyCode] == 58)
{
if ([event modifierFlags] == 524576)
{
NSLog(@"ALT hold");
}
else
{
NSLog(@"ALT release");
}
}
// CTRL
if ([event keyCode] == 59)
{
if ([event modifierFlags] == 262401)
{
NSLog(@"CTRL hold");
}
else
{
NSLog(@"CTRL release");
}
}
}];