private static Keys KeyTranslate(Windows.System.VirtualKey inkey, CorePhysicalKeyStatus keyStatus) { switch (inkey) { // WinRT does not distinguish between left/right keys // We have to check for special keys such as control/shift/alt/ etc case Windows.System.VirtualKey.Control: // we can detect right Control by checking the IsExtendedKey value. return((keyStatus.IsExtendedKey) ? Keys.RightControl : Keys.LeftControl); case Windows.System.VirtualKey.Shift: // we can detect right shift by checking the scancode value. // left shift is 0x2A, right shift is 0x36. IsExtendedKey is always false. return((keyStatus.ScanCode == 0x36) ? Keys.RightShift : Keys.LeftShift); // Note that the Alt key is now refered to as Menu. // ALT key doesn't get fired by KeyUp/KeyDown events. // One solution could be to check CoreWindow.GetKeyState(...) on every tick. case Windows.System.VirtualKey.Menu: return(Keys.LeftAlt); default: return((Keys)inkey); } }
private async void Page_KeyDown(object sender,Windows.System.VirtualKey e) { if (e == Windows.System.VirtualKey.RightShift) { //C_MAINSPLITVIEW.IsPaneOpen = true; } }
private async void Page_KeyUp(object sender,Windows.System.VirtualKey e) { if (e == Windows.System.VirtualKey.Shift) { // C_MAINSPLITVIEW.IsPaneOpen = !C_MAINSPLITVIEW.IsPaneOpen; } }
private void Grid_KeyUp(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e) { Windows.System.VirtualKey key = e.Key; switch (key) { case Windows.System.VirtualKey.Up: upKeyPressed = false; break; case Windows.System.VirtualKey.Down: downKeyPressed = false; break; case Windows.System.VirtualKey.Left: leftKeyPressed = false; break; case Windows.System.VirtualKey.Right: rightKeyPressed = false; break; case Windows.System.VirtualKey.A: letterAKeyPressed = false; break; //case Windows.System.VirtualKey.Escape: // escapeKeyPressed = false; // break; default: break; } }
public static bool IsKeyHex(Windows.System.VirtualKey k) { if (k == Windows.System.VirtualKey.A || k == Windows.System.VirtualKey.B || k == Windows.System.VirtualKey.C || k == Windows.System.VirtualKey.D || k == Windows.System.VirtualKey.E || k == Windows.System.VirtualKey.F || k == Windows.System.VirtualKey.Number0 || k == Windows.System.VirtualKey.Number1 || k == Windows.System.VirtualKey.Number2 || k == Windows.System.VirtualKey.Number3 || k == Windows.System.VirtualKey.Number4 || k == Windows.System.VirtualKey.Number5 || k == Windows.System.VirtualKey.Number6 || k == Windows.System.VirtualKey.Number7 || k == Windows.System.VirtualKey.Number8 || k == Windows.System.VirtualKey.Number9 || k == Windows.System.VirtualKey.Space || k == Windows.System.VirtualKey.Subtract) { return(true); } else { return(false); } }
private static void NavigateModeByShortcut(bool controlKeyPressed, bool shiftKeyPressed, bool altPressed , Windows.System.VirtualKey key, ViewMode?toMode) { var lookupMap = GetCurrentKeyDictionary(controlKeyPressed, shiftKeyPressed, altPressed); if (lookupMap != null) { var listItems = EqualRange(lookupMap, (MyVirtualKey)key); foreach (var itemRef in listItems) { if (itemRef.Target is MUXC.NavigationView item) { var navView = item; var menuItems = ((List <object>)navView.MenuItemsSource); if (menuItems != null) { var vm = (navView.DataContext as ApplicationViewModel); if (null != vm) { ViewMode realToMode = toMode.HasValue ? toMode.Value : NavCategoryStates.GetViewModeForVirtualKey(((MyVirtualKey)key)); var nvi = menuItems[NavCategoryStates.GetFlatIndex(realToMode)]; if (CanNavigateModeByShortcut(navView, nvi, vm, realToMode)) { vm.Mode = realToMode; navView.SelectedItem = nvi; } } } break; } } } }
public void OnKeyUp(Windows.System.VirtualKey virtualKey) { KeyAction keyAction = _controlScheme.GetAction(virtualKey); if (KeyActionToDirection(keyAction) == _currentMoveDirection) { _resetDirectionFlag = true; } }
private void Tb_KeyDown(object sender, KeyRoutedEventArgs e) { if (editor == null) { return; } LastKeyDown = e.Key; }
internal void KeyUp(Windows.System.VirtualKey virtualKey) { if (virtualKey == Windows.System.VirtualKey.Left) { _leftAction = null; } if (virtualKey == Windows.System.VirtualKey.Right) { _righrAction = null; } }
public void KeyDown(Windows.System.VirtualKey key) { if (key == Windows.System.VirtualKey.U) { model.Celsius += 10; } if (key == Windows.System.VirtualKey.D) { model.Celsius -= 10; } }
private void CreateKeyboardAccelerator(Windows.System.VirtualKey key, Windows.System.VirtualKeyModifiers modifiers = Windows.System.VirtualKeyModifiers.Control) { if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "KeyboardAccelerators")) { var accelerator = new KeyboardAccelerator { Modifiers = modifiers, Key = key, ScopeOwner = this }; accelerator.Invoked += FlyoutAccelerator_Invoked; Transport.KeyboardAccelerators.Add(accelerator); } }
private async Task HandleKeyPress(Windows.System.VirtualKey key) { await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { if (key == Windows.System.VirtualKey.T && speechSynth != null && speechSynth.Visibility == Visibility.Visible) { await TogglePlayTextToSpeech(); } }); }
/// <summary> /// Default Hardware/Shell Back handler overrides standard Back behavior /// that navigates to previous app in the app stack to instead cause a backward page navigation. /// Views or Viewodels can override this behavior by handling the BackRequested /// event and setting the Handled property of the BackRequestedEventArgs to true. /// </summary> private void RaiseBackRequested(Windows.System.VirtualKey key, ref bool handled) { DebugWrite(); var args = new HandledEventArgs(); BackRequested?.Invoke(null, args); if (handled = args.Handled) { return; } var popups = VisualTreeHelper.GetOpenPopups(Window.Current); foreach (var popup in popups) { if (popup.Child is INavigablePage page) { page.OnBackRequested(args); if (handled = args.Handled) { return; } } else if (popup.Child is ContentDialog dialog) { dialog.Hide(); return; } else if (key == Windows.System.VirtualKey.Escape) { handled = args.Handled = true; return; } } foreach (var frame in WindowContext.GetForCurrentView().NavigationServices.Select(x => x.FrameFacade).Reverse()) { frame.RaiseBackRequested(args); if (handled = args.Handled) { return; } } if (NavigationService?.CanGoBack ?? false) { NavigationService?.GoBack(); } }
public void OnKeyDown(Windows.System.VirtualKey virtualKey) { KeyAction keyAction = _controlScheme.GetAction(virtualKey); if (keyAction == KeyAction.PlaceBomb) { DropBomb(); return; } Direction direction = KeyActionToDirection(keyAction); _currentMoveDirection = KeyActionToDirection(keyAction); _firstMove = true; }
public void OnKeyPressed(Windows.System.VirtualKey key) { mutex.WaitOne(); if (mainView.VirtualKey == key) { mainView.KeyCount += 1; } else { mainView.VirtualKey = key; mainView.KeyCount = 1; } mutex.ReleaseMutex(); }
private void Tb_KeyUp(object sender, KeyRoutedEventArgs e) { if (editor == null) { return; } if (e.Key == Windows.System.VirtualKey.Enter && LastKeyDown == Windows.System.VirtualKey.Control) { editor.SetEvent_CtrlEnter(); } LastKeyDown = Windows.System.VirtualKey.Delete; }
internal void KeyDown(Windows.System.VirtualKey virtualKey) { if (virtualKey == Windows.System.VirtualKey.Space) { _model.PlayerShot(); } if (virtualKey == Windows.System.VirtualKey.Left) { _leftAction = DateTime.Now; } if (virtualKey == Windows.System.VirtualKey.Right) { _righrAction = DateTime.Now; } }
public VirtualKey(int gridrow, int gridcolumn, Windows.System.VirtualKey key, List <string> characters) { Margin = new Thickness(3); BorderBrush = new SolidColorBrush(Colors.Gray); Background = new SolidColorBrush(Colors.Black) { Opacity = 0.9 }; Foreground = new SolidColorBrush(Colors.White); Width = 50; Height = 40; GridRow = gridrow; GridColumn = gridcolumn; Key = key; Characters = characters; SetContent(); }
private void Number1Box_KeyDown(object sender, KeyRoutedEventArgs e) { if (tempKey != null && tempKey == Windows.System.VirtualKey.Shift) { e.Handled = true; } else { e.Handled = !e.Key.ToString().Contains("Number"); } tempKey = e.Key; if (e.Key == Windows.System.VirtualKey.Enter) { Reset1Box(); } }
private static Keys KeyTranslate(Windows.System.VirtualKey inkey) { switch (inkey) { // XNA does not have have 'handless' key values. // So, we arebitrarily map those to the 'Left' version. case Windows.System.VirtualKey.Control: return(Keys.LeftControl); case Windows.System.VirtualKey.Shift: return(Keys.LeftShift); // Note that the Alt key is now refered to as Menu. case Windows.System.VirtualKey.Menu: return(Keys.LeftAlt); default: return((Keys)inkey); } }
private async void OnPhoneBox_KeyDown(object sender, KeyRoutedEventArgs e) { if (tempKey != null && tempKey == Windows.System.VirtualKey.Shift) { e.Handled = true; } else { e.Handled = !e.Key.ToString().Contains("Number"); } tempKey = e.Key; if (e.Key == Windows.System.VirtualKey.Enter) { ShowPin(); await Task.Delay(2000); InsertMethod(); } }
internal void KeyUp(VirtualKey virtualKey) { if (virtualKey == VirtualKey.Left) _leftAction = null; if (virtualKey == VirtualKey.Right) _rightAction = null; }
internal void KeyDown(VirtualKey virtualKey) { if (virtualKey == VirtualKey.Space) _model.FireShot(); if (virtualKey == VirtualKey.Left) _leftAction = DateTime.Now; if (virtualKey == VirtualKey.Right) _rightAction = DateTime.Now; }
public void Input(Windows.System.VirtualKey keyPress) { _you.Input(keyPress); }
public static bool IsBackOrEscapeKey(Windows.System.VirtualKey key) { return(key == Windows.System.VirtualKey.Back || key == Windows.System.VirtualKey.Escape); }
private void ViewportOperations(Windows.System.VirtualKey args) { var ttv = rect.TransformToVisual(grid); Point screenCoords = ttv.TransformPoint(new Point(0, 0)); var ttvcanvas = PreviewCanvas.TransformToVisual(grid); Point screenCoordscanvas = ttvcanvas.TransformPoint(new Point(0, 0)); if (args == Windows.System.VirtualKey.Add && rect.ActualWidth + 10 <= previewElement.ActualWidth && rect.ActualHeight <= previewElement.ActualHeight) { rect.Width = rect.ActualWidth + 10; rect.Height = rect.ActualWidth + 10; } else if (args == Windows.System.VirtualKey.Subtract && rect.Width - 10 >= 0) { rect.Width = rect.ActualWidth - 10; rect.Height = rect.ActualWidth - 10; } else if (args == Windows.System.VirtualKey.Left && screenCoords.X - 10 >= 0 && screenCoords.X > screenCoordscanvas.X) { rect.Margin = new Thickness(rect.Margin.Left - 10, rect.Margin.Top, rect.Margin.Right + 10, rect.Margin.Bottom); } else if (args == Windows.System.VirtualKey.Right && screenCoords.X + 10 <= screenCoordscanvas.X + PreviewCanvas.Width - rect.ActualWidth) { var pending = (screenCoordscanvas.X + PreviewCanvas.Width - rect.ActualWidth) - (screenCoords.X + 10 + rect.ActualWidth); if (pending < 10 && pending >= 0) { //edge case rect.Margin = new Thickness(rect.Margin.Left + pending, rect.Margin.Top, rect.Margin.Right - pending, rect.Margin.Bottom); } else { rect.Margin = new Thickness(rect.Margin.Left + 10, rect.Margin.Top, rect.Margin.Right - 10, rect.Margin.Bottom); } } else if (args == Windows.System.VirtualKey.Up && screenCoords.Y - 10 >= 0 && screenCoords.Y > screenCoordscanvas.Y) { var pending = screenCoords.Y - 10; if (pending < 10) { rect.Margin = new Thickness(rect.Margin.Left, rect.Margin.Top - pending, rect.Margin.Right, rect.Margin.Bottom + pending); } else { rect.Margin = new Thickness(rect.Margin.Left, rect.Margin.Top - 10, rect.Margin.Right, rect.Margin.Bottom + 10); } } else if (args == Windows.System.VirtualKey.Down && screenCoords.Y + 10 <= screenCoordscanvas.Y + PreviewCanvas.Height - rect.ActualHeight) { var pending = (screenCoordscanvas.Y + PreviewCanvas.Height - rect.ActualHeight) - (screenCoords.Y + 10 + rect.ActualHeight); if (pending < 10 && pending >= 0) { //edge case rect.Margin = new Thickness(rect.Margin.Left, rect.Margin.Top + pending, rect.Margin.Right, rect.Margin.Bottom - pending); } else { rect.Margin = new Thickness(rect.Margin.Left, rect.Margin.Top + 10, rect.Margin.Right, rect.Margin.Bottom - 10); } } }
public static bool ProcessVirualKey(VisualElement element, Windows.System.VirtualKey virtualKey) { if (element == null) { return(false); } keyDownCaptured = false; string keyInput; switch (virtualKey) { case Windows.System.VirtualKey.Back: keyInput = Forms9Patch.HardwareKey.BackspaceDeleteKeyInput; break; case Windows.System.VirtualKey.Delete: keyInput = Forms9Patch.HardwareKey.ForwardDeleteKeyInput; break; case Windows.System.VirtualKey.Down: keyInput = Forms9Patch.HardwareKey.DownArrowKeyInput; break; case Windows.System.VirtualKey.End: keyInput = Forms9Patch.HardwareKey.EndKeyInput; break; case Windows.System.VirtualKey.Escape: keyInput = Forms9Patch.HardwareKey.EscapeKeyInput; break; case Windows.System.VirtualKey.Enter: keyInput = Forms9Patch.HardwareKey.EnterReturnKeyInput; break; case Windows.System.VirtualKey.F1: keyInput = Forms9Patch.HardwareKey.F1KeyInput; break; case Windows.System.VirtualKey.F2: keyInput = Forms9Patch.HardwareKey.F2KeyInput; break; case Windows.System.VirtualKey.F3: keyInput = Forms9Patch.HardwareKey.F3KeyInput; break; case Windows.System.VirtualKey.F4: keyInput = Forms9Patch.HardwareKey.F4KeyInput; break; case Windows.System.VirtualKey.F5: keyInput = Forms9Patch.HardwareKey.F5KeyInput; break; case Windows.System.VirtualKey.F6: keyInput = Forms9Patch.HardwareKey.F6KeyInput; break; case Windows.System.VirtualKey.F7: keyInput = Forms9Patch.HardwareKey.F7KeyInput; break; case Windows.System.VirtualKey.F8: keyInput = Forms9Patch.HardwareKey.F8KeyInput; break; case Windows.System.VirtualKey.F9: keyInput = Forms9Patch.HardwareKey.F9KeyInput; break; case Windows.System.VirtualKey.F10: keyInput = Forms9Patch.HardwareKey.F10KeyInput; break; case Windows.System.VirtualKey.F11: keyInput = Forms9Patch.HardwareKey.F11KeyInput; break; case Windows.System.VirtualKey.F12: keyInput = Forms9Patch.HardwareKey.F12KeyInput; break; case Windows.System.VirtualKey.Home: keyInput = Forms9Patch.HardwareKey.HomeKeyInput; break; case Windows.System.VirtualKey.Insert: keyInput = Forms9Patch.HardwareKey.InsertKeyInput; break; case Windows.System.VirtualKey.Left: keyInput = Forms9Patch.HardwareKey.LeftArrowKeyInput; break; case Windows.System.VirtualKey.PageDown: keyInput = Forms9Patch.HardwareKey.PageDownKeyInput; break; case Windows.System.VirtualKey.PageUp: keyInput = Forms9Patch.HardwareKey.PageUpKeyInput; break; case Windows.System.VirtualKey.Right: keyInput = Forms9Patch.HardwareKey.RightArrowKeyInput; break; case Windows.System.VirtualKey.Up: keyInput = Forms9Patch.HardwareKey.UpArrowKeyInput; break; /* * case Windows.System.VirtualKey.NumberPad0: * keyInput = Forms9Patch.HardwareKey.Numpad0; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.NumberPad1: * keyInput = Forms9Patch.HardwareKey.Numpad1; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.NumberPad2: * keyInput = Forms9Patch.HardwareKey.Numpad2; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.NumberPad3: * keyInput = Forms9Patch.HardwareKey.Numpad3; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.NumberPad4: * keyInput = Forms9Patch.HardwareKey.Numpad4; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.NumberPad5: * keyInput = Forms9Patch.HardwareKey.Numpad5; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.NumberPad6: * keyInput = Forms9Patch.HardwareKey.Numpad6; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.NumberPad7: * keyInput = Forms9Patch.HardwareKey.Numpad7; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.NumberPad8: * keyInput = Forms9Patch.HardwareKey.Numpad8; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.NumberPad9: * keyInput = Forms9Patch.HardwareKey.Numpad9; * keyDownCaptured = true; * break; * * case Windows.System.VirtualKey.Number0: * keyInput = "0"; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.Number1: * keyInput = "1"; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.Number2: * keyInput = "2"; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.Number3: * keyInput = "3"; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.Number4: * keyInput = "4"; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.Number5: * keyInput = "5"; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.Number6: * keyInput = "6"; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.Number7: * keyInput = "7"; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.Number8: * keyInput = "8"; * keyDownCaptured = true; * break; * case Windows.System.VirtualKey.Number9: * keyInput = "9"; * keyDownCaptured = true; * break; */ default: return(false); } var modifiers = GetModifierKeys(true); //var result = new Forms9Patch.HardwareKey(keyInput, GetModifierKeys()); var listeners = element.GetHardwareKeyListeners(); #pragma warning disable CC0006 // Use foreach for (int i = 0; i < listeners.Count; i++) #pragma warning restore CC0006 // Use foreach { var listener = listeners[i]; if (string.IsNullOrEmpty(listener?.HardwareKey?.KeyInput)) { continue; } if (listener.HardwareKey.KeyInput == keyInput && (listener.HardwareKey.ModifierKeys == modifiers || listener.HardwareKey.ModifierKeys == HardwareKeyModifierKeys.Any)) { if (listener.Command != null && listener.Command.CanExecute(listener.CommandParameter)) { listener.Command.Execute(listener.CommandParameter); } listener.Pressed?.Invoke(element, new HardwareKeyEventArgs(listener.HardwareKey, element)); //System.Diagnostics.Debug.WriteLine("SUCCESS!!!"); return(true); } } //System.Diagnostics.Debug.WriteLine("CoreWindow.KeyDown ["+args.VirtualKey+"] dev:["+args.DeviceId+"] handled["+args.Handled+"]" + KeyStatusString(args.KeyStatus)); return(false); }
protected virtual void OnKeyPressed(Windows.System.VirtualKey key) { }
internal void HandleKeyPressed(Windows.System.VirtualKey key) => OnKeyPressed(key);
private static bool IsDown(Windows.System.VirtualKey key) { return(Window.Current.CoreWindow.GetKeyState(key).HasFlag(CoreVirtualKeyStates.Down)); }
public virtual bool IsKeyPressed(Windows.System.VirtualKey key) { return(CoreWindow.GetAsyncKeyState(key) != CoreVirtualKeyStates.None); }
public static Windows.UI.Core.CoreVirtualKeyStates GetKeyStateForCurrentThread(Windows.System.VirtualKey virtualKey) => Xaml.Window.Current.CoreWindow.GetKeyState(virtualKey);