1

Is there a way to detect when the Caps Lock key is pressed down or released? I'm not talking about Caps Lock flag being on or off. I'm talking about if there are key up or down events which I can monitor in CGEvent (doesn't have to be CGEvent, can be another API).

I know it should be possible on OS/Software level because in System Preferences > Keyboard > Modifier Keys... it's possible to make Caps Lock act like a Command button. Which means OS X knows when Caps Lock is Up or Down.

Nikolozi
  • 2,212
  • 2
  • 19
  • 29
  • If you have an NSEvent, you can call `[-NSEvent keyCode]` on it. Does that give you the keycode for the CapsLock key? – user1118321 Oct 05 '12 at 05:11
  • I can't use NSEvent as I'm trying to capture the keyboard events globally, not just the ones sent to my app. – Nikolozi Oct 05 '12 at 05:47
  • See [this answer](http://stackoverflow.com/questions/5993633/how-to-get-keyboard-state-in-objective-c-without-referring-to-nsevent). – user1118321 Oct 05 '12 at 15:26
  • I found the answer here: http://stackoverflow.com/questions/7190852/using-iohidmanager-to-get-modifier-key-events It uses IOKit. – Nikolozi Oct 12 '12 at 06:01

0 Answers0