Keyboard.IsKeyUp(Key) 方法

定义

确定指定的键是否处于松开状态。Determines whether the specified key is released.

public:
 static bool IsKeyUp(System::Windows::Input::Key key);
public static bool IsKeyUp (System.Windows.Input.Key key);
static member IsKeyUp : System.Windows.Input.Key -> bool

参数

key
Key

要检查的键。The key to check.

返回

如果 true 处于松开状态,则为 key;否则为 falsetrue if key is in the up state; otherwise, false.

示例

下面的示例演示如何使用 IsKeyUp 方法来确定特定键的状态。The following example shows how to use the IsKeyUp method to determine the state of a specific key. Return 键传递给 IsKeyUp 方法。The Return key is passed to the IsKeyUp method. 如果该方法返回 true,则 Button 的背景会发生更改。If the method returns true, then the background of a Button is changed.

// Uses the Keyboard.IsKeyUp to determine if a key is up.
if (Keyboard.IsKeyUp(Key.Return))
{
    btnIsUp.Background = Brushes.Red;
}
else
{
    btnIsUp.Background = Brushes.AliceBlue;
}
' Uses the Keyboard.IsKeyUp to determine if a key is up.
If Keyboard.IsKeyUp(Key.Return) Then
    btnIsUp.Background = Brushes.Red
Else
    btnIsUp.Background = Brushes.AliceBlue
End If

注解

GetKeyStates 方法可用于确定特定键的状态集。The GetKeyStates method can be used to determine the set of states of a specific key.

适用于

另请参阅