Keyboard.Modifiers Property

Gets the set of ModifierKeys which are currently pressed.

Namespace: System.Windows.Input
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

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

public static function get Modifiers () : ModifierKeys

You cannot use this property in XAML.

Property Value

The set of modifier keys.

ModifierKeys is a bit field enumeration, so it is possible for multiple modifier keys to be pressed at the same time. Use bit operations to determine the exact set of modifier keys pressed.

The following using a bit AND operation to determine if the Control modifier key is pressed.

if ((Keyboard.Modifiers & ModifierKeys.Control) > 0)
{
    button1.Background = Brushes.Red;
}
else
{
    button1.Background = Brushes.Blue;
}

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

Community Additions

ADD
Show: