private void CoreWindow_KeyDown(CoreWindow sender, KeyEventArgs args) { CoreVirtualKeyStates shift = Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift); bool isShift = shift.HasFlag(CoreVirtualKeyStates.Down); switch (args.VirtualKey) { case VirtualKey.Down: _playerDirection.Down = true; break; case VirtualKey.Left: _playerDirection.Left = true; break; case VirtualKey.Right: _playerDirection.Right = true; break; case VirtualKey.Up: _playerDirection.Up = true; break; default: break; } }
private void OnPageKeyDown(object sender, KeyRoutedEventArgs e) { if (e.Key == VirtualKey.S) { CoreVirtualKeyStates controlState = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control); if (controlState.HasFlag(CoreVirtualKeyStates.Down) && ViewModel.Save.CanExecute()) { ViewModel.Save.Execute(); e.Handled = true; } } }
private void OnKeyDown(object sender, KeyRoutedEventArgs e) { CoreVirtualKeyStates ctrl = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control); if (ctrl.HasFlag(CoreVirtualKeyStates.Down)) { if (e.OriginalKey == VirtualKey.S) { ViewModel.Save.Execute(null); } else if (e.OriginalKey == VirtualKey.D) { ViewModel.Delete.Execute(null); } } }