Handling global KeyDown event in Windows 8 / WinRT


I was searching for a way to handle the KeyDown or KeyUp event for a ScrollViewer in a Windows 8 Metro / WinRT app. The events just doesn't fire for the ScrollViewer.

But I found a nice workaround, it's possible to handle the KeyDown/KeyUp event for the whole page by subscribing to the events:
Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;
Window.Current.CoreWindow.KeyUp += CoreWindow_KeyUp;

This is also very useful when implementing "type to search" functionality like on the Windows 8 start screen.


Roman 30-05-2013
After I navigated from my page (I clicked the button for raising the navigatedFrom event), and after again navigated to this page key up and key down events not firing. I waited some seconds and beaten on the keyboard - after that key up/down events is firing well. What happening with key up and down events?

New Comment

E-mail (not published)
Enter the code shown: