I’m trying to trigger an event when the user presses ctrl–x using the KeyDown event. This works fine for ctrl–D but the event doesn’t trigger when ctrl–x is pressed. I’m guessing this is because ctrl–x is the “cut” command. Is there any way to trigger an event when ctrl–X is pressed?
private void textBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) || e.KeyboardDevice.IsKeyDown(Key.RightCtrl))
{
switch (e.Key)
{
case Key.D:
//handle D key
break;
case Key.X:
//handle X key
break;
}
}
}
You can override the existing cut command:
You need to create a command though.