Gets the set of key states for the specified key.
Assembly: PresentationCore (in PresentationCore.dll)
'Declaration Public Shared Function GetKeyStates ( _ key As Key _ ) As KeyStates 'Usage Dim key As Key Dim returnValue As KeyStates returnValue = Keyboard.GetKeyStates(key)
- Type: System.Windows.Input.Key
The specified key.
KeyStates is a bit field enumeration; therefore, it is possible for a key to be in multiple states. For example, a key could be in the pressed state as well as in the toggled state. Use bit comparison operations to determine the exact state or states the key is in.
The following example shows how to use the method to determine if the Return key is in the Down state. A bit AND operation is used to compare the KeyStates returned from and the Down state. If the key is down, the background of a Button is changed.
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.