Export (0) Print
Expand All
Expand Minimize

ModifierKeys Enumeration

Specifies the set of modifier keys.

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

Namespace:  System.Windows.Input
Assembly:  WindowsBase (in WindowsBase.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

[TypeConverterAttribute(typeof(ModifierKeysConverter))]
[FlagsAttribute]
public enum ModifierKeys
<object property="oneOrMoreModifierKeys"/>

XAML Values

oneOrMoreModifierKeys

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

Member nameDescription
NoneNo modifiers are pressed.
AltThe ALT key.
ControlThe CTRL key.
ShiftThe SHIFT key.
WindowsThe Windows logo key.

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.

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);

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0

Community Additions

ADD
Show:
© 2014 Microsoft