As per requirement I need to capture the event of Key combination of two character and One control key(Example (ALT+S+C). How can I implement the same.
Thanks Ranish
Using the KeyDown
event:
if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt) // Is Alt key pressed
{
if (Keyboard.IsKeyDown(Key.S) && Keyboard.IsKeyDown(Key.C))
{
// do something here
}
}
EDIT: Modified code. Using both Gesture
and Key
properties is not possible. The last declared property will be used as the key and the key specified in the Gesture
property will be ignored.
The following code is only possible with 2 ModifierKeys, not 2 Keys:
<KeyBinding Gesture="Alt+Shift+C" Command="{Binding ACommand}"/>
To implement Key combinations with 2 Keys and a single ModifierKey
the following article looks quite useful:
KeyGesture with Multiple Keys
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