The most relevant properties of KeyRoutedEventArgs for most handler scenarios are Key and possibly KeyStatus. The delegate for handlers is KeyEventHandler. For keyboard events, that data will be an instance of KeyRoutedEventArgs. The sender reports the object where the event handler is attached. Keyboard event handlersĪn input event handler implements a delegate that provides the following information: For more info, see Implementing keyboard accessibility. However, you can modify this order by using the TabIndex property. You can also respond to a control that is receiving or losing focus by handling the GotFocus and LostFocus events.īy default, the tab sequence of controls is the order in which they appear in the Extensible Application Markup Language (XAML). When a control has input focus, it can raise and respond to keyboard input events as described later in this topic.
![keyboard maestro gesture trigger example keyboard maestro gesture trigger example](https://forum.keyboardmaestro.com/uploads/default/optimized/3X/f/9/f9a6859ffbecf4759b2c31c2a528ba4c3f0d9bb8_2_1035x798.png)
This is the default state for most controls. For more info, see the Shortcut keys example later in this topic.įor a control to receive input focus, it must be enabled, visible, and have IsTabStop and HitTestVisible property values of true. This is necessary when you implement shortcut keys, because keyboard focus is not set by default when your UI loads. You can also call a control's Focus method to force focus. An individual control gains focus when the user clicks or taps directly on that control in the layout, or uses the Tab key to step into a tab sequence within the content area.
![keyboard maestro gesture trigger example keyboard maestro gesture trigger example](https://community.folivora.ai/uploads/default/original/2X/d/d8c99496edda473bf6628815fedbf84b49feeff9.jpeg)
For more info about how class-based handling of events works (specifically, the "Input event handlers in controls" section), see Events and routed events overview.Ĭontrols in your UI generate keyboard events only when they have input focus.
![keyboard maestro gesture trigger example keyboard maestro gesture trigger example](http://www.macdrifter.com/uploads/2018/02/ScreenShot20180217_094221.jpg)
Keys other than Space or Enter still fire KeyDown and KeyUp events. This provides a built-in keyboard equivalent for invoking the button, similar to tapping it with a finger or clicking it with a mouse. When a key press is handled by the control class, the KeyDown and KeyUp events are not raised. For example, the Button class overrides the OnKeyDown events for both the Space key and the Enter key (as well as OnPointerPressed) and routes them to the Click event of the control. Typically, this subset of keys is processed by the class handler to provide built in support of basic keyboard accessibility. In these cases, it might appear that an input event doesn't occur because your event listener doesn't invoke the associated handler. Some XAML controls handle input events internally.