I know how to detect a keystroke. All keys except Control, Alt, Shift and CMD.
How can I detect when these keys are pressed.
Thanks in advance.
If you want to discover these keys in something like an object NSView, look at the class NSResponder. When you overwrite a class NSView(or one of its subclasses), you can overwrite keyDown:(NSEvent *)theEvent (Apple Documentation) . When you call [theEvent modifierFlags], a bit field is returned NSUInteger, which you can then evaluate.
NSView
NSResponder
keyDown:(NSEvent *)theEvent
[theEvent modifierFlags]
NSUInteger
For example, with
if ([theEvent modifierFlags] & NSCommandKeyMask) { ... }
. Apple Cocoa , " ".
- (void) flagsChanged: (NSEvent *)theEvent
[theEvent keyCode] CRTL, SHIFT, ALT .., , 0 .
[theEvent keyCode]
CRTL
SHIFT
ALT
0
OpenGL, :
-(BOOL) canBecomeKeyWindow