According to the docs:
Tells the recipient that the user pressed or released the modifier (Shift, Control, etc.).
What you need to do when you receive an event in which the command key is reset, you need to set the flag somewhere, and in subsequent calls - check the absence of the pressed command key.
For example, if you have ivar called _cmdKeyDown :
- (void)flagsChanged:(NSEvent *)theEvent { [super flagsChanged:theEvent]; NSUInteger f = [theEvent modifierFlags]; BOOL isDown = !!(f & NSCommandKeyMask); if (isDown != _cmdKeyDown) { NSLog(@"State changed. Cmd Key is: %@", isDown ? @"Down" : @"Up"); _cmdKeyDown = isDown; } }
ipmcc source share