How to detect ALT (Menu) button keydown on global

2019-09-16 23:47发布

I use following code to detect all key events in a WinRT app page:

Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;
...

private void CoreWindow_KeyDown(CoreWindow sender, KeyEventArgs args)
{
  //Handle key event
}

But the Alt (Menu in the VirtualKey enumeration) key does not trigger the CoreWindow.KeyDown event. It does also block any other key to trigger the event while pressed.

Anyone know how to detect the Alt keydown event on a global page level in a WinRT app?

1条回答
狗以群分
2楼-- · 2019-09-17 00:31

It seems to be a bug Unexpected behavior in Windows.Core.UI.CorePhysicalKeyStatus.IsMenuKeyDown.

Though I tried Dispatcher.AcceleratorKeyActivated, it handles Alt key.

查看更多
登录 后发表回答