ConsoleKey 列挙型

定義

コンソールの標準キーを指定します。Specifies the standard keys on a console.

public enum class ConsoleKey
public enum ConsoleKey
[System.Serializable]
public enum ConsoleKey
type ConsoleKey = 
Public Enum ConsoleKey
継承
ConsoleKey
属性

フィールド

A 65

A キー。The A key.

Add 107

加算キー (テンキーの加算記号キー)。The Add key (the addition key on the numeric keypad).

Applications 93

アプリケーション キー (Microsoft Natural Keyboard)。The Application key (Microsoft Natural Keyboard).

Attention 246

Attn キー。The ATTN key.

B 66

B キー。The B key.

Backspace 8

BackSpace キー。The BACKSPACE key.

BrowserBack 166

ブラウザーの戻るキー。The Browser Back key.

BrowserFavorites 171

ブラウザーのお気に入りキー。The Browser Favorites key.

BrowserForward 167

ブラウザーの進むキー。The Browser Forward key.

BrowserHome 172

ブラウザーのホーム キー。The Browser Home key.

BrowserRefresh 168

ブラウザーの更新キー。The Browser Refresh key.

BrowserSearch 170

ブラウザーの検索キー。The Browser Search key.

BrowserStop 169

ブラウザーの中止キー。The Browser Stop key.

C 67

C キー。The C key.

Clear 12

Clear キー。The CLEAR key.

CrSel 247

CRSEL (Cursor Select) キー。The CRSEL (CURSOR SELECT) key.

D 68

D キー。The D key.

D0 48

0 キー。The 0 key.

D1 49

1 キー。The 1 key.

D2 50

2 キー。The 2 key.

D3 51

3 キー。The 3 key.

D4 52

4 キー。The 4 key.

D5 53

5 キー。The 5 key.

D6 54

6 キー。The 6 key.

D7 55

7 キー。The 7 key.

D8 56

8 キー。The 8 key.

D9 57

9 キー。The 9 key.

Decimal 110

小数点キー (テンキーの小数点記号キー)。The Decimal key (the decimal key on the numeric keypad).

Delete 46

Delete キー。The DEL (DELETE) key.

Divide 111

除算キー (テンキーの除算記号キー)。The Divide key (the division key on the numeric keypad).

DownArrow 40

↓キー。The DOWN ARROW key.

E 69

E キー。The E key.

End 35

End キー。The END key.

Enter 13

Enter キー。The ENTER key.

EraseEndOfFile 249

Erase Eof キー。The ERASE EOF key.

Escape 27

Esc キー。The ESC (ESCAPE) key.

Execute 43

Execute キー。The EXECUTE key.

ExSel 248

Exsel (Extend Selection) キー。The EXSEL (EXTEND SELECTION) key.

F 70

F キー。The F key.

F1 112

F1 キー。The F1 key.

F10 121

F10 キー。The F10 key.

F11 122

F11 キー。The F11 key.

F12 123

F12 キー。The F12 key.

F13 124

F13 キー。The F13 key.

F14 125

F14 キー。The F14 key.

F15 126

F15 キー。The F15 key.

F16 127

F16 キー。The F16 key.

F17 128

F17 キー。The F17 key.

F18 129

F18 キー。The F18 key.

F19 130

F19 キー。The F19 key.

F2 113

F2 キー。The F2 key.

F20 131

F20 キー。The F20 key.

F21 132

F21 キー。The F21 key.

F22 133

F22 キー。The F22 key.

F23 134

F23 キー。The F23 key.

F24 135

F24 キー。The F24 key.

F3 114

F3 キー。The F3 key.

F4 115

F4 キー。The F4 key.

F5 116

F5 キー。The F5 key.

F6 117

F6 キー。The F6 key.

F7 118

F7 キー。The F7 key.

F8 119

F8 キー。The F8 key.

F9 120

F9 キー。The F9 key.

G 71

G キー。The G key.

H 72

H キー。The H key.

Help 47

Help キー。The HELP key.

Home 36

Home キー。The HOME key.

I 73

I キー。The I key.

Insert 45

Insert キー。The INS (INSERT) key.

J 74

J キー。The J key.

K 75

K キー。The K key.

L 76

L キー。The L key.

LaunchApp1 182

アプリケーションの起動 1 キー (Microsoft Natural Keyboard)。The Start Application 1 key (Microsoft Natural Keyboard).

LaunchApp2 183

アプリケーションの起動 2 キー (Microsoft Natural Keyboard)。The Start Application 2 key (Microsoft Natural Keyboard).

LaunchMail 180

メールの起動キー (Microsoft Natural Keyboard)。The Start Mail key (Microsoft Natural Keyboard).

LaunchMediaSelect 181

メディアの選択キー (Microsoft Natural Keyboard)。The Select Media key (Microsoft Natural Keyboard).

LeftArrow 37

←キー。The LEFT ARROW key.

LeftWindows 91

左 Windows ロゴ キー (Microsoft Natural Keyboard)。The left Windows logo key (Microsoft Natural Keyboard).

M 77

M キー。The M key.

MediaNext 176

メディアの次のトラック キー。The Media Next Track key.

MediaPlay 179

メディアの再生/一時停止キー。The Media Play/Pause key.

MediaPrevious 177

メディアの前のトラック キー。The Media Previous Track key.

MediaStop 178

メディアの停止キー。The Media Stop key.

Multiply 106

乗算キー (テンキーの乗算記号キー)。The Multiply key (the multiplication key on the numeric keypad).

N 78

N キー。The N key.

NoName 252

将来使用するために予約されている定数。A constant reserved for future use.

NumPad0 96

0 キー (テンキー)。The 0 key on the numeric keypad.

NumPad1 97

1 キー (テンキー)。The 1 key on the numeric keypad.

NumPad2 98

2 キー (テンキー)。The 2 key on the numeric keypad.

NumPad3 99

3 キー (テンキー)。The 3 key on the numeric keypad.

NumPad4 100

4 キー (テンキー)。The 4 key on the numeric keypad.

NumPad5 101

5 キー (テンキー)。The 5 key on the numeric keypad.

NumPad6 102

6 キー (テンキー)。The 6 key on the numeric keypad.

NumPad7 103

7 キー (テンキー)。The 7 key on the numeric keypad.

NumPad8 104

8 キー (テンキー)。The 8 key on the numeric keypad.

NumPad9 105

9 キー (テンキー)The 9 key on the numeric keypad.

O 79

O キー。The O key.

Oem1 186

OEM 1 キー (OEM 固有)。The OEM 1 key (OEM specific).

Oem102 226

OEM 102 キー (OEM 固有)。The OEM 102 key (OEM specific).

Oem2 191

OEM 2 キー (OEM 固有)。The OEM 2 key (OEM specific).

Oem3 192

OEM 3 キー (OEM 固有)。The OEM 3 key (OEM specific).

Oem4 219

OEM 4 キー (OEM 固有)。The OEM 4 key (OEM specific).

Oem5 220

OEM 5 キー (OEM 固有)。The OEM 5 (OEM specific).

Oem6 221

OEM 6 キー (OEM 固有)。The OEM 6 key (OEM specific).

Oem7 222

OEM 7 キー (OEM 固有)。The OEM 7 key (OEM specific).

Oem8 223

OEM 8 キー (OEM 固有)。The OEM 8 key (OEM specific).

OemClear 254

Clear キー (OEM 固有)。The CLEAR key (OEM specific).

OemComma 188

国または地域別キーボード上の OEM コンマ キー。The OEM Comma key on any country/region keyboard.

OemMinus 189

国または地域別キーボード上の OEM マイナス キー。The OEM Minus key on any country/region keyboard.

OemPeriod 190

国または地域別キーボード上の OEM ピリオド キー。The OEM Period key on any country/region keyboard.

OemPlus 187

国または地域別キーボード上の OEM プラス キー。The OEM Plus key on any country/region keyboard.

P 80

P キー。The P key.

Pa1 253

PA1 キー。The PA1 key.

Packet 231

Packet キー (キーストロークで Unicode 文字を渡すために使用)。The PACKET key (used to pass Unicode characters with keystrokes).

PageDown 34

Page Down キー。The PAGE DOWN key.

PageUp 33

Page Up キー。The PAGE UP key.

Pause 19

Pause キー。The PAUSE key.

Play 250

Play キー。The PLAY key.

Print 42

Print キー。The PRINT key.

PrintScreen 44

Print Screen キー。The PRINT SCREEN key.

Process 229

ME PROCESS キー。The IME PROCESS key.

Q 81

Q キー。The Q key.

R 82

R キー。The R key.

RightArrow 39

→キー。The RIGHT ARROW key.

RightWindows 92

右 Windows ロゴ キー (Microsoft Natural Keyboard)。The right Windows logo key (Microsoft Natural Keyboard).

S 83

S キー。The S key.

Select 41

Select キー。The SELECT key.

Separator 108

区切り記号キー。The Separator key.

Sleep 95

コンピューターのスリープ キー。The Computer Sleep key.

Spacebar 32

Space キー。The SPACEBAR key.

Subtract 109

減算キー (テンキーの減算記号キー)。The Subtract key (the subtraction key on the numeric keypad).

T 84

T キー。The T key.

Tab 9

Tab キー。The TAB key.

U 85

U キー。The U key.

UpArrow 38

↑キー。The UP ARROW key.

V 86

V キー。The V key.

VolumeDown 174

音量下げるキー (Microsoft Natural Keyboard)。The Volume Down key (Microsoft Natural Keyboard).

VolumeMute 173

音量ミュート キー (Microsoft Natural Keyboard)。The Volume Mute key (Microsoft Natural Keyboard).

VolumeUp 175

音量上げるキー (Microsoft Natural Keyboard)。The Volume Up key (Microsoft Natural Keyboard).

W 87

W キー。The W key.

X 88

X キー。The X key.

Y 89

Y キー。The Y key.

Z 90

Z キー。The Z key.

Zoom 251

Zoom キー。The ZOOM key.

次の例では、ConsoleKey 列挙体を使用して、ユーザーが押されたキーをユーザーに示します。The following example uses the ConsoleKey enumeration to indicate to the user which key the user had pressed.

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.
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 メソッドによって返されます。The ConsoleKey enumeration is typically used in the nfo structure, which is returned by the Console.ReadKey method to indicate which key on the console has been pressed.

適用対象