Keyboard.IsKeyUp(Key) 方法

定義

判斷指定的按鍵是否為已放開。

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
Public Shared Function IsKeyUp (key As Key) As Boolean

參數

key
Key

要進行檢查的按鍵。

傳回

如果 key 為已放開狀態則為 true,否則為 false

範例

下列範例示範如何使用 IsKeyUp 方法來判斷特定索引鍵的狀態。 金鑰 Return 會傳遞至 IsKeyUp 方法。 如果方法傳 true回 ,則會變更的背景 Button

// 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方法可用來判斷特定索引鍵的一組狀態。

適用於

另請參閱