Keyboard.IsKeyDown(Key) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정한 키가 눌러져 있는지 여부를 확인합니다.
public:
static bool IsKeyDown(System::Windows::Input::Key key);
public static bool IsKeyDown(System.Windows.Input.Key key);
static member IsKeyDown : System.Windows.Input.Key -> bool
Public Shared Function IsKeyDown (key As Key) As Boolean
매개 변수
- key
- Key
지정한 키입니다.
반환
key가 눌러져 있으면 true이고, 그렇지 않으면 false입니다.
예제
다음 예제에서는 사용 하는 방법의 IsKeyDown 특정 키의 상태를 확인 하는 방법입니다. 합니다 Return 키에 전달 되는 IsKeyDown 메서드. 메서드에서 반환 되 면 true, 배경의 Button 변경 됩니다.
// Uses the Keyboard.IsKeyDown to determine if a key is down.
// e is an instance of KeyEventArgs.
if (Keyboard.IsKeyDown(Key.Return))
{
btnIsDown.Background = Brushes.Red;
}
else
{
btnIsDown.Background = Brushes.AliceBlue;
}
' Uses the Keyboard.IsKeyDown to determine if a key is down.
' e is an instance of KeyEventArgs.
If Keyboard.IsKeyDown(Key.Return) Then
btnIsDown.Background = Brushes.Red
Else
btnIsDown.Background = Brushes.AliceBlue
End If
설명
GetKeyStates 메서드는 특정 키 상태 집합을 결정 데 사용할 수 있습니다.