KeyStates 열거형

정의

키의 상태를 정의하는 상수를 지정합니다.

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

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

필드

Down 1

키가 눌러져 있습니다.

None 0

키가 눌러져 있지 않습니다.

Toggled 2

키가 전환되었습니다.

예제

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

// 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 비트 필드(비트 단위) 열거형입니다. 따라서 키를 여러 상태에 있을 수 있습니다. 예를 들어 키는 상태와 Toggled 상태에 있을 Down 수 있습니다. 비트 연산자를 사용 하 여 키의 정확한 상태를 확인 합니다.

적용 대상

추가 정보