Last active
August 29, 2015 14:16
-
-
Save igorkulman/b0f41a1a25acad0d17a4 to your computer and use it in GitHub Desktop.
Global Backspace key handler for Windows 8.1 apps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Window.Current.CoreWindow.KeyUp += (_, args) => | |
{ | |
if (args.VirtualKey == VirtualKey.Back) | |
{ | |
var element = FocusManager.GetFocusedElement(); | |
if (element is TextBox || element is PasswordBox) | |
{ | |
return; //do not disturb user when typing | |
} | |
var frame = (Frame)Window.Current.Content; | |
if (frame.CanGoBack) | |
{ | |
frame.GoBack(); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment