KeyboardAccelerator Class
Definition
Represents a keyboard shortcut (or accelerator) that lets a user perform an action using the keyboard instead of navigating the app UI (directly or through access keys).
Accelerators are typically assigned to buttons or menu items.
Equivalent WinUI class: Microsoft.UI.Xaml.Input.KeyboardAccelerator.
/// [Windows.Foundation.Metadata.Composable(Windows.UI.Xaml.Input.IKeyboardAcceleratorFactory, Windows.Foundation.Metadata.CompositionType.Public, 327680, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 327680)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Static(Windows.UI.Xaml.Input.IKeyboardAcceleratorStatics, 327680, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.WebHostHidden]
class KeyboardAccelerator : DependencyObject
[Windows.Foundation.Metadata.Composable(typeof(Windows.UI.Xaml.Input.IKeyboardAcceleratorFactory), Windows.Foundation.Metadata.CompositionType.Public, 327680, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 327680)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Static(typeof(Windows.UI.Xaml.Input.IKeyboardAcceleratorStatics), 327680, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.WebHostHidden]
public class KeyboardAccelerator : DependencyObject
Public Class KeyboardAccelerator
Inherits DependencyObject
- Inheritance
- Attributes
Windows 10 requirements
Device family |
Windows 10 Fall Creators Update (introduced in 10.0.16299.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v5.0)
|
Remarks
An accelerator key can be a single key, such as F1 - F12 and Esc, or a combination of keys (Ctrl + Shift + B, or Ctrl C) that invoke a command. They differ from access keys (mnemonics), which are typically modified with the Alt key and simply activate a command or control.
An accelerator can be executed even if the element associated with the accelerator is not visible. For example, an item in the SecondaryCommands collection of the CommandBar can be invoked using an accelerator without expanding the overflow menu and displaying the element.
By default, an accelerator has global scope. However, you can constrain scope using ScopeOwner or disable an accelerator completely using IsEnabled.
Constructors
KeyboardAccelerator() |
Initializes a new instance of the KeyboardAccelerator class. Equivalent WinUI constructor: Microsoft.UI.Xaml.Input.KeyboardAccelerator.KeyboardAccelerator. |
Properties
Dispatcher |
Gets the CoreDispatcher that this object is associated with. The CoreDispatcher represents a facility that can access the DependencyObject on the UI thread even if the code is initiated by a non-UI thread. Equivalent WinUI property: Microsoft.UI.Xaml.DependencyObject.Dispatcher. (Inherited from DependencyObject) |
IsEnabled |
Gets or sets whether a keyboard shortcut (accelerator) is available to the user. Equivalent WinUI property: Microsoft.UI.Xaml.Input.KeyboardAccelerator.IsEnabled. |
IsEnabledProperty |
Identifies the IsEnabled dependency property. Equivalent WinUI property: Microsoft.UI.Xaml.Input.KeyboardAccelerator.IsEnabledProperty. |
Key |
Gets or sets the virtual key (used in conjunction with one or more modifier keys) for a keyboard shortcut (accelerator). A keyboard shortcut is invoked when the modifier keys associated with the shortcut are pressed and then the non-modifier key is pressed at the same time. For example, Ctrl+C for copy and Ctrl+S for save. Equivalent WinUI property: Microsoft.UI.Xaml.Input.KeyboardAccelerator.Key. |
KeyProperty |
Identifies the Key dependency property. Equivalent WinUI property: Microsoft.UI.Xaml.Input.KeyboardAccelerator.KeyProperty. |
Modifiers |
Gets or sets the virtual key used to modify another keypress for a keyboard shortcut (accelerator). A keyboard shortcut is invoked when the modifier keys associated with the shortcut are pressed and then the non-modifier key is pressed at the same time. For example, Ctrl+C for copy and Ctrl+S for save. Equivalent WinUI property: Microsoft.UI.Xaml.Input.KeyboardAccelerator.Modifiers. |
ModifiersProperty |
Identifies the Modifiers dependency property. Equivalent WinUI property: Microsoft.UI.Xaml.Input.KeyboardAccelerator.ModifiersProperty. |
ScopeOwner |
Gets or sets the scope (or target) of the keyboard accelerator. Equivalent WinUI property: Microsoft.UI.Xaml.Input.KeyboardAccelerator.ScopeOwner. |
ScopeOwnerProperty |
Identifies the ScopeOwner dependency property. Equivalent WinUI property: Microsoft.UI.Xaml.Input.KeyboardAccelerator.ScopeOwnerProperty. |
Methods
Events
Invoked |
Occurs when the key combination for this KeyboardAccelerator is pressed. Equivalent WinUI event: Microsoft.UI.Xaml.Input.KeyboardAccelerator.Invoked. |