I'm implementing a WPF application in C# 4.5 for Windows 7, and I would like to be able to grab the event when a user presses the Windows Key and C.
I've implemented the OnPreviewKeyDownEvent and this fires as expected (in my code I have some other events that fire off other key presses), however it seems only the Windows Key down fires, and not the second key press. I can see this from the debug.Writeline command.
Any ideas how I capture both the windows Key and C?
private void OnPreviewKeyDownEvent(object sender, KeyEventArgs e)
{
if ((e.Key == Key.C && (Keyboard.Modifiers & ModifierKeys.Windows) == ModifierKeys.Windows) && e.IsDown)
Messagbox.Show("Pressed1");
if (e.Key == Key.C && (Keyboard.IsKeyDown(Key.LWin) || Keyboard.IsKeyDown(Key.RWin)))
Messenger.Default.Send(new RightClickMessage())
Messagbox.Show("Pressed2");
System.Diagnostics.Debug.WriteLine(e.Key + " " + Keyboard.IsKeyDown(Key.LWin) + " ");
}
Many thanks in advance for your help.