How do I capture a keyboard shortcut, no matter which control has focus? I don't want to go and write the same thing for each possible control that the user could give focus to. So how can I watch for a page-wide/control-independent shortcut?
Add this code to the constructor it will handle a global key down and key
Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;
Window.Current.CoreWindow.KeyUp += CoreWindow_KeyUp;
heres their events
void CoreWindow_KeyUp(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.KeyEventArgs args)
{
//this.Frame.Navigate(typeof(MainPage));
var key = args.VirtualKey;
string aa = args.ToString();
}
void CoreWindow_KeyDown(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.KeyEventArgs args)
{
//this.Frame.Navigate(typeof(MainPage));
var key = args.VirtualKey;
string aa = args.ToString();
}
you can ahndle your own logic inside this event.