How do I detect when a shortcut key such as Ctrl + O is pressed in a WPF (independently of any particular control)?
I tried capturing KeyDown
but the KeyEventArgs
doesn't tell me whether or not Control or Alt is down.
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyboardDevice.Modifiers == ModifierKeys.Control)
{
// CTRL is down.
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With