ConsoleKey Wyliczenie

Definicja

Określa klucze standardowe w konsoli.

public enum class ConsoleKey
public enum ConsoleKey
[System.Serializable]
public enum ConsoleKey
type ConsoleKey = 
[<System.Serializable>]
type ConsoleKey = 
Public Enum ConsoleKey
Dziedziczenie
ConsoleKey
Atrybuty

Pola

A 65

Klucz A.

Add 107

Dodaj klucz (klucz dodawania na klawiaturze liczbowej).

Applications 93

Klawisz aplikacji (Microsoft Natural Keyboard).

Attention 246

Klucz ATTN.

B 66

Klucz B.

Backspace 8

Klucz BACKSPACE.

BrowserBack 166

Klucz wstecz przeglądarki.

BrowserFavorites 171

Klucz Ulubione przeglądarki.

BrowserForward 167

Klucz przekazywania w przeglądarce.

BrowserHome 172

Klucz główny przeglądarki.

BrowserRefresh 168

Klucz odświeżania przeglądarki.

BrowserSearch 170

Klucz wyszukiwania przeglądarki.

BrowserStop 169

Klucz zatrzymania przeglądarki.

C 67

Klucz C.

Clear 12

Klucz CLEAR.

CrSel 247

Klucz CRSEL (CURSOR SELECT).

D 68

Klucz D.

D0 48

Klucz 0.

D1 49

Klucz 1.

D2 50

Klucz 2.

D3 51

Klucz 3.

D4 52

Klucz 4.

D5 53

Klucz 5.

D6 54

Klucz 6.

D7 55

Klucz 7.

D8 56

Klucz 8.

D9 57

Klucz 9.

Decimal 110

Klucz dziesiętny (klucz dziesiętny na klawiaturze liczbowej).

Delete 46

Klucz DEL (DELETE).

Divide 111

Klucz dzielenia (klucz dzielenia na klawiaturze liczbowej).

DownArrow 40

Klawisz STRZAŁKI W DÓŁ.

E 69

Klucz E.

End 35

Klucz END.

Enter 13

Klucz ENTER.

EraseEndOfFile 249

Klucz ERASE EOF.

Escape 27

Klucz ESC (ESCAPE).

Execute 43

Klucz EXECUTE.

ExSel 248

Klucz EXSEL (EXTEND SELECTION).

F 70

Klawisz F.

F1 112

Klawisz F1.

F10 121

Klucz F10.

F11 122

Klucz F11.

F12 123

Klucz F12.

F13 124

Klucz F13.

F14 125

Klucz F14.

F15 126

Klawisz F15.

F16 127

Klawisz F16.

F17 128

Klucz F17.

F18 129

Klawisz F18.

F19 130

Klucz F19.

F2 113

Klucz F2.

F20 131

Klucz F20.

F21 132

Klucz F21.

F22 133

Klucz F22.

F23 134

Klucz F23.

F24 135

Klucz F24.

F3 114

Klawisz F3.

F4 115

Klucz F4.

F5 116

Klawisz F5.

F6 117

Klawisz F6.

F7 118

Klawisz F7.

F8 119

Klawisz F8.

F9 120

Klawisz F9.

G 71

Klucz G.

H 72

Klucz H.

Help 47

Klucz HELP.

Home 36

Klucz HOME.

I 73

Klucz I.

Insert 45

Klucz INS (INSERT).

J 74

Klucz J.

K 75

Klucz K.

L 76

Klucz L.

LaunchApp1 182

Klawisz Start Application 1 (Microsoft Natural Keyboard).

LaunchApp2 183

Klawisz Start Application 2 (Microsoft Natural Keyboard).

LaunchMail 180

Klawisz Start Mail (Microsoft Natural Keyboard).

LaunchMediaSelect 181

Wybierz klawisz multimediów (Microsoft Natural Keyboard).

LeftArrow 37

Klawisz STRZAŁKA W LEWO.

LeftWindows 91

Lewy Windows klawisz logo (Microsoft Natural Keyboard).

M 77

Klucz M.

MediaNext 176

Klucz Media Next Track.

MediaPlay 179

Klucz odtwarzania/wstrzymania multimediów.

MediaPrevious 177

Klucz poprzedniego śledzenia multimediów.

MediaStop 178

Klucz zatrzymania multimediów.

Multiply 106

Klucz mnożenia (klucz mnożenia na klawiaturze liczbowej).

N 78

Klucz N.

NoName 252

Stała zarezerwowana do użytku w przyszłości.

NumPad0 96

Klucz 0 na klawiaturze liczbowej.

NumPad1 97

1 klucz na klawiaturze liczbowej.

NumPad2 98

Klucz 2 na klawiaturze liczbowej.

NumPad3 99

3 klucz na klawiaturze liczbowej.

NumPad4 100

4 klucz na klawiaturze liczbowej.

NumPad5 101

5 klawiszy na klawiaturze liczbowej.

NumPad6 102

Klucz 6 na klawiaturze liczbowej.

NumPad7 103

Klucz 7 na klawiaturze liczbowej.

NumPad8 104

Klucz 8 na klawiaturze liczbowej.

NumPad9 105

Klucz 9 na klawiaturze liczbowej.

O 79

Klucz O.

Oem1 186

Klucz OEM 1 (specyficzny dla producenta OEM).

Oem102 226

Klucz OEM 102 (specyficzny dla producenta OEM).

Oem2 191

Klucz OEM 2 (specyficzny dla producenta OEM).

Oem3 192

Klucz OEM 3 (specyficzny dla producenta OEM).

Oem4 219

Klucz OEM 4 (specyficzny dla producenta OEM).

Oem5 220

OEM 5 (specyficzny dla producenta OEM).

Oem6 221

Klucz OEM 6 (specyficzny dla producenta OEM).

Oem7 222

Klucz OEM 7 (specyficzny dla producenta OEM).

Oem8 223

Klucz OEM 8 (specyficzny dla producenta OEM).

OemClear 254

Klucz CLEAR (specyficzny dla producenta OEM).

OemComma 188

Klawisz przecinka OEM na dowolnej klawiaturze kraju/regionu.

OemMinus 189

Klawisz OEM Minus na dowolnej klawiaturze kraju/regionu.

OemPeriod 190

Klawisz okresu OEM na dowolnej klawiaturze kraju/regionu.

OemPlus 187

Klawisz OEM Plus na dowolnej klawiaturze kraju/regionu.

P 80

Klucz P.

Pa1 253

Klucz PA1.

Packet 231

Klucz PACKET (używany do przekazywania znaków Unicode za pomocą naciśnięć klawiszy).

PageDown 34

Klucz PAGE DOWN.

PageUp 33

Klucz PAGE UP.

Pause 19

Klucz PAUSE.

Play 250

Klucz PLAY.

Print 42

Klucz PRINT.

PrintScreen 44

Klucz PRINT SCREEN.

Process 229

Klucz procesu IME.

Q 81

Klucz Q.

R 82

Klucz języka R.

RightArrow 39

Klawisz STRZAŁKA W PRAWO.

RightWindows 92

Prawy Windows klawisz logo (Microsoft Natural Keyboard).

S 83

Klucz S.

Select 41

Klucz SELECT.

Separator 108

Klucz separatora.

Sleep 95

Klucz uśpienia komputera.

Spacebar 32

Klucz SPACEBAR.

Subtract 109

Klucz odejmowania (klucz odejmowania na klawiaturze liczbowej).

T 84

Klucz T.

Tab 9

Klawisz TAB.

U 85

Klucz U.

UpArrow 38

Klawisz STRZAŁKA W GÓRĘ.

V 86

Klucz V.

VolumeDown 174

Klawisz w dół woluminu (Klawiatura naturalna firmy Microsoft).

VolumeMute 173

Klawisz wyciszenia woluminu (Microsoft Natural Keyboard).

VolumeUp 175

Klawisz Volume Up (Microsoft Natural Keyboard).

W 87

Klucz W.

X 88

Klucz X.

Y 89

Klucz Y.

Z 90

Klucz Z.

Zoom 251

Klucz ZOOM.

Przykłady

W poniższym przykładzie użyto wyliczenia ConsoleKey , aby wskazać użytkownikowi, który klucz został naciśnięty przez użytkownika.

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.

Uwagi

Wyliczenie ConsoleKey jest zwykle używane w strukturze nfo, która jest zwracana przez Console.ReadKey metodę, aby wskazać, który klucz w konsoli został naciśnięty.

Dotyczy