ConsoleKey 열거형

정의

콘솔의 표준 키를 지정합니다.

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

필드

A 65

A 키입니다.

Add 107

더하기 키(숫자 키패드의 더하기 키).

Applications 93

애플리케이션 키(Microsoft Natural 키보드)입니다.

Attention 246

ATTN 키입니다.

B 66

B 키입니다.

Backspace 8

백스페이스 키입니다.

BrowserBack 166

브라우저 뒤로 키입니다.

BrowserFavorites 171

브라우저 즐겨찾기 키입니다.

BrowserForward 167

브라우저 앞으로 키입니다.

BrowserHome 172

브라우저 홈 키입니다.

BrowserRefresh 168

브라우저 새로 고침 키입니다.

BrowserSearch 170

브라우저 검색 키입니다.

BrowserStop 169

브라우저 중지 키입니다.

C 67

C 키입니다.

Clear 12

지우기 키입니다.

CrSel 247

CRSEL(CURSOR SELECT) 키입니다.

D 68

D 키입니다.

D0 48

0 키입니다.

D1 49

1 키입니다.

D2 50

2 키입니다.

D3 51

3 키입니다.

D4 52

4 키입니다.

D5 53

5 키입니다.

D6 54

6 키입니다.

D7 55

7 키입니다.

D8 56

8 키입니다.

D9 57

9 키입니다.

Decimal 110

점 키(숫자 키패드의 점 키).

Delete 46

Del(Delete) 키입니다.

Divide 111

나누기 키(숫자 키패드의 나누기 키).

DownArrow 40

아래쪽 화살표 키입니다.

E 69

E 키입니다.

End 35

&lt;End&gt; 키입니다.

Enter 13

&lt;Enter&gt; 키입니다.

EraseEndOfFile 249

ERASE EOF 키입니다.

Escape 27

Esc(ESCAPE) 키입니다.

Execute 43

실행 키입니다.

ExSel 248

EXSEL(EXTEND SELECTION) 키입니다.

F 70

F 키입니다.

F1 112

F1 키입니다.

F10 121

F10 키입니다.

F11 122

F11 키입니다.

F12 123

F12 키입니다.

F13 124

F13 키입니다.

F14 125

F14 키입니다.

F15 126

F15 키입니다.

F16 127

F16 키입니다.

F17 128

F17 키입니다.

F18 129

F18 키입니다.

F19 130

F19 키입니다.

F2 113

F2 키입니다.

F20 131

F20 키입니다.

F21 132

F21 키입니다.

F22 133

F22 키입니다.

F23 134

F23 키입니다.

F24 135

F24 키입니다.

F3 114

F3 키입니다.

F4 115

F4 키입니다.

F5 116

F5 키입니다.

F6 117

F6 키입니다.

F7 118

F7 키입니다.

F8 119

F8 키입니다.

F9 120

F9 키입니다.

G 71

G 키입니다.

H 72

H 키입니다.

Help 47

도움말 키입니다.

Home 36

HOME 키입니다.

I 73

I 키입니다.

Insert 45

Insert 키입니다.

J 74

J 키입니다.

K 75

K 키입니다.

L 76

L 키입니다.

LaunchApp1 182

애플리케이션 1 시작 키(Microsoft Natural 키보드)입니다.

LaunchApp2 183

애플리케이션 2 시작 키(Microsoft Natural 키보드)입니다.

LaunchMail 180

메일 실행 키(Microsoft Natural 키보드)입니다.

LaunchMediaSelect 181

미디어 선택 키(Microsoft Natural 키보드)입니다.

LeftArrow 37

왼쪽 화살표 키입니다.

LeftWindows 91

왼쪽 Windows 로고 키(Microsoft Natural 키보드)입니다.

M 77

M 키입니다.

MediaNext 176

미디어 다음 트랙 키입니다.

MediaPlay 179

미디어 재생/일시 중지 키입니다.

MediaPrevious 177

미디어 이전 트랙 키입니다.

MediaStop 178

미디어 중지 키입니다.

Multiply 106

곱하기 키(숫자 키패드의 곱하기 키).

N 78

N 키입니다.

NoName 252

나중에 사용하기 위해 예약된 상수입니다.

NumPad0 96

숫자 키패드의 0 키입니다.

NumPad1 97

숫자 키패드의 1 키입니다.

NumPad2 98

숫자 키패드의 2 키입니다.

NumPad3 99

숫자 키패드의 3 키입니다.

NumPad4 100

숫자 키패드의 4 키입니다.

NumPad5 101

숫자 키패드의 5 키입니다.

NumPad6 102

숫자 키패드의 6 키입니다.

NumPad7 103

숫자 키패드의 7 키입니다.

NumPad8 104

숫자 키패드의 8 키입니다.

NumPad9 105

숫자 키패드의 9 키입니다.

O 79

O 키입니다.

Oem1 186

OEM 1 키(OEM 특정)입니다.

Oem102 226

OEM 102 키(OEM 특정)입니다.

Oem2 191

OEM 2 키(OEM 특정)입니다.

Oem3 192

OEM 3 키(OEM 특정)입니다.

Oem4 219

OEM 4 키(OEM 특정)입니다.

Oem5 220

OEM 5 키(OEM 특정)입니다.

Oem6 221

OEM 6 키(OEM 특정)입니다.

Oem7 222

OEM 7 키(OEM 특정)입니다.

Oem8 223

OEM 8 키(OEM 특정)입니다.

OemClear 254

지우기 키(OEM 특정)입니다.

OemComma 188

국가/지역별 키보드의 OEM 쉼표 키입니다.

OemMinus 189

국가/지역별 키보드의 OEM 빼기 키입니다.

OemPeriod 190

국가/지역별 키보드의 OEM 마침표 키입니다.

OemPlus 187

국가/지역별 키보드의 OEM 더하기 키입니다.

P 80

P 키입니다.

Pa1 253

PA1 키입니다.

Packet 231

패킷 키(키 입력으로 유니코드 문자를 전달하는 데 사용)입니다.

PageDown 34

&lt;Page Down&gt; 키입니다.

PageUp 33

&lt;Page Up&gt; 키입니다.

Pause 19

&lt;Pause&gt; 키입니다.

Play 250

재생 키입니다.

Print 42

인쇄 키입니다.

PrintScreen 44

&lt;Print Screen&gt; 키입니다.

Process 229

입력기 프로세스 키입니다.

Q 81

Q 키입니다.

R 82

R 키입니다.

RightArrow 39

오른쪽 화살표 키입니다.

RightWindows 92

오른쪽 Windows 로고 키(Microsoft Natural 키보드)입니다.

S 83

S 키입니다.

Select 41

선택 키입니다.

Separator 108

구분 기호 키입니다.

Sleep 95

컴퓨터 절전 키입니다.

Spacebar 32

스페이스바 키입니다.

Subtract 109

빼기 키(숫자 키패드의 빼기 키).

T 84

T 키입니다.

Tab 9

&lt;Tab&gt; 키입니다.

U 85

U 키입니다.

UpArrow 38

위쪽 화살표 키입니다.

V 86

V 키입니다.

VolumeDown 174

볼륨 작게 키(Microsoft Natural 키보드)입니다.

VolumeMute 173

볼륨 음소거 키(Microsoft Natural 키보드)입니다.

VolumeUp 175

볼륨 크게 키(Microsoft Natural 키보드)입니다.

W 87

W 키입니다.

X 88

X 키입니다.

Y 89

Y 키입니다.

Z 90

Z 키입니다.

Zoom 251

확대/축소 키입니다.

예제

다음 예제에서는 열거형을 ConsoleKey 사용하여 사용자가 누른 키를 사용자에게 나타냅니다.

using namespace System;
using namespace System::Text;

void main()
{
   ConsoleKeyInfo input;
   do {
      Console::WriteLine("Press a key, together with Alt, Ctrl, or Shift.");
      Console::WriteLine("Press Esc to exit.");
      input = Console::ReadKey(true);

      StringBuilder^ output = gcnew StringBuilder(
                     String::Format("You pressed {0}", input.Key.ToString()));
      bool modifiers = false;

      if ((input.Modifiers & ConsoleModifiers::Alt) == ConsoleModifiers::Alt) {
         output->Append(", together with " + ConsoleModifiers::Alt.ToString());
         modifiers = true;
      }
      if ((input.Modifiers & ConsoleModifiers::Control) == ConsoleModifiers::Control)
      {
         if (modifiers) {
            output->Append(" and ");
         }   
         else {
            output->Append(", together with ");
            modifiers = true;
         }
         output->Append(ConsoleModifiers::Control.ToString());
      }
      if ((input.Modifiers & ConsoleModifiers::Shift) == ConsoleModifiers::Shift)
      {
         if (modifiers) {
            output->Append(" and ");
         }   
         else {
            output->Append(", together with ");
            modifiers = true;
         }
         output->Append(ConsoleModifiers::Shift.ToString());
      }
      output->Append(".");                  
      Console::WriteLine(output->ToString());
      Console::WriteLine();
   } while (input.Key != ConsoleKey::Escape);
}
// The output from a sample console session might appear as follows:
//       Press a key, along with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed D.
//       
//       Press a key, along with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed X, along with Shift.
//       
//       Press a key, along with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed L, along with Control and Shift.
//       
//       Press a key, along with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed P, along with Alt and Control and Shift.
//       
//       Press a key, along with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed Escape.
using System;
using System.Text;

public class ConsoleKeyExample
{
   public static void Main()
   {
      ConsoleKeyInfo input;
      do {
         Console.WriteLine("Press a key, together with Alt, Ctrl, or Shift.");
         Console.WriteLine("Press Esc to exit.");
         input = Console.ReadKey(true);

         StringBuilder output = new StringBuilder(
                       String.Format("You pressed {0}", input.Key.ToString()));
         bool modifiers = false;

         if ((input.Modifiers & ConsoleModifiers.Alt) == ConsoleModifiers.Alt) {
            output.Append(", together with " + ConsoleModifiers.Alt.ToString());
            modifiers = true;
         }
         if ((input.Modifiers & ConsoleModifiers.Control) == ConsoleModifiers.Control)
         {
            if (modifiers) {
               output.Append(" and ");
            }
            else {
               output.Append(", together with ");
               modifiers = true;
            }
            output.Append(ConsoleModifiers.Control.ToString());
         }
         if ((input.Modifiers & ConsoleModifiers.Shift) == ConsoleModifiers.Shift)
         {
            if (modifiers) {
               output.Append(" and ");
            }
            else {
               output.Append(", together with ");
               modifiers = true;
            }
            output.Append(ConsoleModifiers.Shift.ToString());
         }
         output.Append(".");
         Console.WriteLine(output.ToString());
         Console.WriteLine();
      } while (input.Key != ConsoleKey.Escape);
   }
}
// The output from a sample console session might appear as follows:
//       Press a key, along with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed D.
//
//       Press a key, along with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed X, along with Shift.
//
//       Press a key, along with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed L, along with Control and Shift.
//
//       Press a key, along with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed P, along with Alt and Control and Shift.
//
//       Press a key, along with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed Escape.
open System
open System.Text

let mutable input = Unchecked.defaultof<ConsoleKeyInfo>

while input.Key <> ConsoleKey.Escape do
    printfn "Press a key, together with Alt, Ctrl, or Shift."
    printfn "Press Esc to exit."
    input <- Console.ReadKey true

    let output = StringBuilder $"You pressed {input.Key}"
    let mutable modifiers = false

    if input.Modifiers &&& ConsoleModifiers.Alt = ConsoleModifiers.Alt then
        output.Append ", together with {ConsoleModifiers.Alt}" |> ignore
        modifiers <- true

    if input.Modifiers &&& ConsoleModifiers.Control = ConsoleModifiers.Control then
        if modifiers then
            output.Append " and " |> ignore
    else
        output.Append ", together with " |> ignore
        modifiers <- true
        output.Append(string ConsoleModifiers.Control) |> ignore

    if input.Modifiers &&& ConsoleModifiers.Shift = ConsoleModifiers.Shift then
        if modifiers then
            output.Append " and " |> ignore
        else
            output.Append ", together with " |> ignore
            modifiers <- true
        output.Append(string ConsoleModifiers.Shift) |> ignore
    output.Append "." |> ignore
    
    printfn $"{output}\n"


// The output from a sample console session might appear as follows:
//       Press a key, along with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed D.
//
//       Press a key, along with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed X, along with Shift.
//
//       Press a key, along with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed L, along with Control and Shift.
//
//       Press a key, along with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed P, along with Alt and Control and Shift.
//
//       Press a key, along with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed Escape.
Imports System.Text

Module ConsoleKeyExample

   Public Sub Main()
      Dim input As ConsoleKeyInfo
      Do 
         Console.WriteLine("Press a key, together with Alt, Ctrl, or Shift.")
         Console.WriteLine("Press Esc to exit.")
         input = Console.ReadKey(True)

         Dim output As New StringBuilder(String.Format("You pressed {0}", input.Key.ToString()))
         Dim modifiers As Boolean

         If (input.Modifiers And ConsoleModifiers.Alt) = ConsoleModifiers.Alt Then
            output.Append(", together with " + ConsoleModifiers.Alt.ToString())
            modifiers = True
         End If
         If (input.Modifiers And ConsoleModifiers.Control) = ConsoleModifiers.Control Then
            If modifiers Then
               output.Append(" and ")
            Else
               output.Append(", together with ")
               modifiers = True
            End If
            output.Append(ConsoleModifiers.Control.ToString)
         End If
         If (input.Modifiers And ConsoleModifiers.Shift) = ConsoleModifiers.Shift Then
            If modifiers Then
               output.Append(" and ")
            Else
               output.Append(", together with ")
            End If
            output.Append(ConsoleModifiers.Shift.ToString)
         End If
         output.Append(".")                  
         Console.WriteLine(output.ToString())
         Console.WriteLine()
      Loop While input.Key <> ConsoleKey.Escape        
   End Sub
End Module
' The output from a sample console session might appear as follows:
'       Press a key, along with Alt, Ctrl, or Shift.
'       Press Esc to exit.
'       You pressed D.
'       
'       Press a key, along with Alt, Ctrl, or Shift.
'       Press Esc to exit.
'       You pressed X, along with Shift.
'       
'       Press a key, along with Alt, Ctrl, or Shift.
'       Press Esc to exit.
'       You pressed L, along with Control and Shift.
'       
'       Press a key, along with Alt, Ctrl, or Shift.
'       Press Esc to exit.
'       You pressed P, along with Alt and Control and Shift.
'       
'       Press a key, along with Alt, Ctrl, or Shift.
'       Press Esc to exit.
'       You pressed Escape.

설명

열거형은 ConsoleKey 일반적으로 nfo 구조에서 사용되며, 콘솔에서 누른 키를 나타내기 위해 메서드에서 반환 Console.ReadKey 됩니다.

적용 대상