|
Q: How do I detect when the caps lock key is turned on or off in my Cocoa application?A: You must implement
The Listing 1: Detecting the caps lock key. - (void)flagsChanged:(NSEvent*)event { if ([event keyCode] == 0x39) // 57 = key code for caps lock { unsigned flags = [event modifierFlags]; if (flags & NSAlphaShiftKeyMask) NSLog(@"capsLock on"); else NSLog(@"capsLock off"); } } Related Documentation
Document Revision History
Posted: 2007-05-11 |
|