detect Ctrl + Enter

c#, keystroke, wpf

Solution

Obviously `e.Key` can'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 as `Control` and `Modifiers` that will help you detect combinations.

The `KeyPress` event, which uses `KeyPressEventArgs`, just doesn't have sufficient information.

Drat, you said WPF didn't you. It looks like you need `e.KeyboardDevice.Modifiers`.

Problem

(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

Original source