I have a ListView
with the following KeyDown
event handler:
private void ListViewOnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.A)
{
Debug.WriteLine("KeyDown is A");
if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
{
ListViewHelper.SelectAll((ListView)sender);
}
}
}
Yet the Debug.WriteLine
is only ever invoked, i.e. I see KeyDown is A
in my output window, if I only press key A
. If I press CTRL
, the event is invoked, but e.Key
shows as LeftCtrl
(using a breakpoint), and hold CTRL
down and press A
, the Debug.WriteLine
is not invoked. Using a breakpoint for debugging shows that while I am holding CTRL
down, the handler keeps getting invoked for LeftCtrl
only.