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 如果 key 处于启动状态,则为 .;否则为 false。
示例
以下示例演示如何使用 IsKeyUp 该方法确定特定键的状态。 密钥 Return 将 IsKeyUp 传递给方法。 如果方法返回 true,则更改 a 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 可用于确定特定键的状态集。