KeyEventArgs.IsDown 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个值,该值指示事件引用的键是否处于关闭状态。
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 返回指定的键是否关闭。