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.

/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 327680)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class KeyboardAccelerator : DependencyObject
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 327680)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public class KeyboardAccelerator : DependencyObject
Public Class KeyboardAccelerator
Inherits DependencyObject
Inheritance
Object IInspectable DependencyObject KeyboardAccelerator
Attributes

Windows 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.

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.

(Inherited from DependencyObject)
IsEnabled

Gets or sets whether a keyboard shortcut (accelerator) is available to the user.

IsEnabledProperty

Identifies the IsEnabled dependency property.

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.

KeyProperty

Identifies the Key dependency property.

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.

ModifiersProperty

Identifies the Modifiers dependency property.

ScopeOwner

Gets or sets the scope (or target) of the keyboard accelerator.

ScopeOwnerProperty

Identifies the ScopeOwner dependency property.

Methods

ClearValue(DependencyProperty)

Clears the local value of a dependency property.

(Inherited from DependencyObject)
GetAnimationBaseValue(DependencyProperty)

Returns any base value established for a dependency property, which would apply in cases where an animation is not active.

(Inherited from DependencyObject)
GetValue(DependencyProperty)

Returns the current effective value of a dependency property from a DependencyObject.

(Inherited from DependencyObject)
ReadLocalValue(DependencyProperty)

Returns the local value of a dependency property, if a local value is set.

(Inherited from DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)

Registers a notification function for listening to changes to a specific DependencyProperty on this DependencyObject instance.

(Inherited from DependencyObject)
SetValue(DependencyProperty, Object)

Sets the local value of a dependency property on a DependencyObject.

(Inherited from DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty, Int64)

Cancels a change notification that was previously registered by calling RegisterPropertyChangedCallback.

(Inherited from DependencyObject)

Events

Invoked

Occurs when the key combination for this KeyboardAccelerator is pressed.

Applies to

See also