Edit

Share via


ModifierKeys Enum

Definition

Specifies the set of modifier keys.

This enumeration supports a bitwise combination of its member values.

public enum class ModifierKeys
[System.ComponentModel.TypeConverter(typeof(System.Windows.Input.ModifierKeysConverter))]
[System.Flags]
public enum ModifierKeys
[<System.ComponentModel.TypeConverter(typeof(System.Windows.Input.ModifierKeysConverter))>]
[<System.Flags>]
type ModifierKeys = 
Public Enum ModifierKeys
Inheritance
ModifierKeys
Attributes

Fields

Name Value Description
None 0

No modifiers are pressed.

Alt 1

The ALT key.

Control 2

The CTRL key.

Shift 4

The SHIFT key.

Windows 8

The Windows logo key.

Examples

The following example shows how to create a KeyBinding that associates a KeyGesture with a RoutedCommand. The KeyBinding uses the ModifierKeys enumeration to specify the modifier key of the gesture.

<Window.InputBindings>
  <KeyBinding Command="ApplicationCommands.Open"
              Gesture="CTRL+R" />
</Window.InputBindings>
// Creating a KeyBinding between the Open command and Ctrl-R
KeyBinding OpenCmdKeyBinding = new KeyBinding(
    ApplicationCommands.Open, 
    Key.R, 
    ModifierKeys.Control);

this.InputBindings.Add(OpenCmdKeyBinding);
' Creating a KeyBinding between the Open command and Ctrl-R
Dim OpenCmdKeyBinding As New KeyBinding(ApplicationCommands.Open, Key.R, ModifierKeys.Control)

Me.InputBindings.Add(OpenCmdKeyBinding)

Remarks

The Modifiers property on the Keyboard class is the set of the modifier keys that are currently pressed.

Some APIs in Windows Presentation Foundation (WPF) that make use of the ModifierKeys enumeration are the Modifiers properties on the Keyboard, KeyBinding, KeyGesture, and MouseGesture classes.

XAML Attribute Usage

<object property="oneOrMoreModifierKeys"/>  

XAML Values

oneOrMoreModifierKeys
One or more modifier keys, defined by the ModifierKeys enumeration, delimited with a "+" character.

Applies to

See also