I want to determine when a combination of type Ctrl-C is pressed in a WPF application. What I read on the Internet says to use the following in the KeyDown (or KeyUp) event:
if ((Keyboard.Modifiers == ModifierKeys.Control) && (e.Key == Key.S))
{
MessageBox.Show("Save!");
}
I'm just trying to figure out how this works. As far as I understand, e.Key contains the key that was pressed that triggered the event, and Keyboard.Modifiers contains information about the state of the control key right now . Can we assume that by the time the KeyDown event is executed, the control key will still be unavailable?
For example, I restart Firefox and it brushes it off by loading a bunch of tabs, and in the meantime I press Ctrl-S in my application. The delay in receiving KeyDown, and the application believes that S. is pressed.
thank
source
share