ModifierKeys ModifierKeys ModifierKeys ModifierKeys Enum

Definition

Specifies the set of modifier keys.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

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

Fields

Alt Alt Alt Alt 1

The ALT key.

Control Control Control Control 2

The CTRL key.

None None None None 0

No modifiers are pressed.

Shift Shift Shift Shift 4

The SHIFT key.

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