I have a WPF application that needs to respond when a modifier key (e.g. Alt or Control) is first pressed. The response needs to occur regardless of whether or not other keys are pressed at the same, so I basically need to be able to tell the instant any of those keys goes down.
The eventing behavior that I'm seeing for modifier keys is different than other keys --- it looks like the KeyDown event and PreviewKeyDown events actually fire when the button comes UP after being pressed, which isn't helpful.
While digging into the event firing issue, I created a timed background loop that polls all of the current key states. Even that isn't working --- if I press down a modifier key, and I don't release the key or press any other keys, this poll incorrectly says that the modifier key is not actually down (indefinitely, until another key gets pressed)
I feel like I must be missing something basic, but no luck so far. Any ideas?