共用方式為


KeyEventArgs.IsDown 屬性

定義

會得到一個值,表示事件所參考的金鑰是否處於關閉狀態。

public:
 property bool IsDown { bool get(); };
public bool IsDown { get; }
member this.IsDown : bool
Public ReadOnly Property IsDown As Boolean

屬性值

true如果鑰匙在下;否則,。 false

範例

以下範例透過取得屬性的狀態IsDown來檢查與 實KeyEventArgs例相關的金鑰是否為 down。

// e is an instance of KeyEventArgs.
// btnIsDown is a Button.
if (e.IsDown)
{
    btnIsDown.Background = Brushes.Red;
}
' e is an instance of KeyEventArgs.
' btnIsDown is a Button.
If e.IsDown Then
    btnIsDown.Background = Brushes.Red

備註

Keyboard 類別也會提供鍵盤按鍵狀態的資訊。 例如,該 IsKeyDown 方法會回傳指定的鍵是否被關閉。

適用於

另請參閱