From the Cocoa event handling guide:
The flagsChanged: method can be useful for detecting the pressing of modifier keys without any other key being pressed simultaneously. For example, if the user presses the Option key by itself, your responder object can detect this in its implementation of flagsChanged:.
More details can be found here.
The documentation for NSResponder also states the following:
flagsChanged:
Informs the receiver that the user has pressed or released a modifier key (Shift, Control, and so on).
— (void)flagsChanged:(NSEvent *)theEvent