通过


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关联的键是否已关闭。

// 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 返回指定的键是否关闭。

适用于

另请参阅