KeyStates 열거형

정의

키의 상태를 정의하는 상수 지정

이 열거형은 멤버 값의 비트 조합을 지원합니다.

public enum class KeyStates
[System.Flags]
public enum KeyStates
[<System.Flags>]
type KeyStates = 
Public Enum KeyStates
상속
KeyStates
특성

필드

Name Description
None 0

키를 누르지 않습니다.

Down 1

키를 누릅니다.

Toggled 2

키가 전환되었습니다.

예제

다음 예제에서는 전달된 키의 색이 Button is인 경우의 색을 변경합니다 KeyStatesKeyEventArgs.Down 키의 상태는 비트 연산을 사용하여 결정됩니다 AND . 동일한 기술을 사용하여 키에 상태 및 상태와 Toggled 같은 Down 여러 상태가 있는지 여부를 확인할 수 있습니다.

// A bitwise AND operation is used in the comparison.
// e is an instance of KeyEventArgs.
// btnDown is a Button.
if ((e.KeyStates & KeyStates.Down) > 0)
{
    btnDown.Background = Brushes.Red;
}
' A bitwise AND operation is used in the comparison.
' e is an instance of KeyEventArgs.
' btnDown is a Button.
If (e.KeyStates And KeyStates.Down) > 0 Then
    btnDown.Background = Brushes.Red

설명

클래스는 KeyStates 비트 필드(비트) 열거형입니다. 따라서 키는 여러 상태에 있을 수 있습니다. 예를 들어 키는 상태와 Down 상태에 있을 Toggled 수 있습니다. 비트 작업을 사용하여 키가 있는 정확한 상태 또는 상태를 확인합니다.

적용 대상

추가 정보