Skip to content

Instantly share code, notes, and snippets.

@igorkulman
Last active August 29, 2015 14:16
Show Gist options
  • Save igorkulman/b0f41a1a25acad0d17a4 to your computer and use it in GitHub Desktop.
Save igorkulman/b0f41a1a25acad0d17a4 to your computer and use it in GitHub Desktop.
Global Backspace key handler for Windows 8.1 apps
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