This documentation is archived and is not being maintained.

KeyGesture.Modifiers Property

Gets the modifier keys associated with this KeyGesture.

Namespace: System.Windows.Input
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:

public ModifierKeys Modifiers { get; }
/** @property */
public ModifierKeys get_Modifiers ()

public function get Modifiers () : ModifierKeys

<object Modifiers="oneOrMoreModifierKeys"/>
 oneOrMoreModifierKeys  One or more modifier keys, defined by the ModifierKeys enumeration, delimited with a "+".  For more information, see the Modifiers property. 

Property Value

The modifier keys associated with the gesture. The default value is None.

In most cases, a KeyGesture must be associated with one or more ModifierKeys. The exceptions to this rule are the function keys and the numeric keypad keys, which can be a valid KeyGesture by themselves. For example, you can create a KeyGesture by using only the F12 key, but to use the X key in a KeyGesture it must be paired with a modifier key.

The following example binds the Close command to a KeyGesture using a KeyBinding. In XAML, the KeyBinding properties Key and Modifiers are converted into a KeyGesture.

<KeyBinding Modifiers="Alt"
            Command="ApplicationCommands.Close" />

KeyGesture CloseCmdKeyGesture = new KeyGesture(
    Key.L, ModifierKeys.Alt);

KeyBinding CloseKeyBinding = new KeyBinding(
    ApplicationCommands.Close, CloseCmdKeyGesture);


Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0