First, you need to be aware that the value returned from -modifierFlags
includes some flags which do not exactly correspond to keys. You should construct a mask which includes all of the flags that you care about (whether you care that they are pressed or not pressed). Pass the flags value through that mask and then compare the result with exactly the combination you want.
For example, if you care about Command, Option, Shift, and Control, and you want to know if exactly Command and Shift are down but the others are not, you could use:
if ((flags & (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask)) == (NSShiftKeyMask|NSCommandKeyMask))
// do something
Update: Here's how to check a variety of combinations:
flags &= NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask;
if (flags == (NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask))
NSLogs(@"Command+Option+Control");
else if (flags == (NSShiftKeyMask|NSCommandKeyMask))
NSLog(@"Command+Shift ");
else if (flags == (NSControlKeyMask|NSCommandKeyMask))
NSLog(@"Command+Control");
else if (flags == (NSAlternateKeyMask|NSCommandKeyMask))
NSLog(@"Command+Option ");