Alex Rivera | Logout

Ctrl key press condition in WPF MouseLeftButtonDown event-handler

Asked 2009-12-07T16:40:57.330
46

How I can add an additional condition for a certain keyboard key, to a WPF MouseLeftButtonDown event-handler?

For example Ctrl + key

private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{         
    ...
}
Edit
Report

1 Answer

43

If you want to detect modifiers only, you can also use:

if (Keyboard.Modifiers == ModifierKeys.Control) {}
if (Keyboard.Modifiers == ModifierKeys.Shift) {}

etc. More here.

answered 2010-05-11T08:52:43.950

Your Answer