(using WPF)
i try to detect when Ctrl + Enter gets hit.
so i tried this code:
if (e.Key == Key.Return && (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl))
{
//Do Something
}
Obviously this is not correct, as it does not work.
Could anyone help me out, explaining what the right way should be ?
thanx
Obviously
e.Keycan’t be equal to more than one different value in the same event.You need to handle one of the events that uses
KeyEventArgs, there you’ll find properties such asControlandModifiersthat will help you detect combinations.The
KeyPressevent, which usesKeyPressEventArgs, just doesn’t have sufficient information.Drat, you said WPF didn’t you. It looks like you need
e.KeyboardDevice.Modifiers.