Keyboard.IsKeyUp(Key) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
決定是否釋放指定的金鑰。
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
關鍵是要檢查。
傳回
true若處於keyUP狀態;否則,。 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 方法可用來確定特定鍵的狀態集合。