ConsoleKey Výčet

Definice

Určuje standardní klíče v konzole.

public enum class ConsoleKey
public enum ConsoleKey
[System.Serializable]
public enum ConsoleKey
type ConsoleKey = 
[<System.Serializable>]
type ConsoleKey = 
Public Enum ConsoleKey
Dědičnost
ConsoleKey
Atributy

Pole

Name Hodnota Description
None 0
Backspace 8

Klávesa BACKSPACE.

Tab 9

Klávesa TAB.

Clear 12

Klávesa CLEAR.

Enter 13

Klávesa ENTER.

Pause 19

Klávesa PAUSE.

Escape 27

Klávesa ESC (ESCAPE)

Spacebar 32

Klávesa MEZERNÍK.

PageUp 33

Klávesa PAGE UP.

PageDown 34

Klávesa PAGE DOWN.

End 35

Klíč END.

Home 36

Klávesa HOME.

LeftArrow 37

Klávesa ŠIPKA VLEVO.

UpArrow 38

Klávesa ŠIPKA NAHORU.

RightArrow 39

Klávesa ŠIPKA VPRAVO.

DownArrow 40

Klávesa ŠIPKA DOLŮ.

Select 41

Klávesa SELECT.

Print 42

Klávesa PRINT.

Execute 43

Klíč EXECUTE.

PrintScreen 44

Klávesa PRINT SCREEN.

Insert 45

Klíč INS (INSERT).

Delete 46

Klíč DEL (DELETE).

Help 47

Klíč NÁPOVĚDy.

D0 48

Klíč 0.

D1 49

Klíč 1.

D2 50

Klíč 2.

D3 51

Klíč 3.

D4 52

Klíč 4.

D5 53

Klíč 5.

D6 54

Klíč 6.

D7 55

Klíč 7.

D8 56

Klíč 8.

D9 57

Klíč 9.

A 65

Klíč A.

B 66

Klíč B.

C 67

Klávesa C.

D 68

Klíč D.

E 69

Klíč E.

F 70

Klávesa F.

G 71

Klávesa G.

H 72

Klávesa H.

I 73

Já klíč.

J 74

Klíč J.

K 75

Klíč K.

L 76

Klávesa L.

M 77

Klávesa M.

N 78

Klíč N.

O 79

Klíč O.

P 80

Klávesa P.

Q 81

Klávesa Q.

R 82

Klávesa R.

S 83

Klíč S.

T 84

Klávesa T.

U 85

Klávesa U.

V 86

Klíč V.

W 87

Klávesa W.

X 88

Klíč X.

Y 89

Klíč Y.

Z 90

Klávesa Z.

LeftWindows 91

Levá klávesa s logem Windows (Microsoft natural keyboard).

RightWindows 92

Pravá klávesa s logem Windows (Microsoft natural keyboard).

Applications 93

Klávesa aplikace (Microsoft přirozené klávesnice).

Sleep 95

Klíč pro režim spánku počítače.

NumPad0 96

Klávesa 0 na numerické klávesnici.

NumPad1 97

1 klávesa na numerické klávesnici.

NumPad2 98

2 klávesa na numerické klávesnici.

NumPad3 99

3 klávesa na numerické klávesnici.

NumPad4 100

4 klávesa na numerické klávesnici.

NumPad5 101

Klávesa 5 na numerické klávesnici.

NumPad6 102

Klávesa 6 na numerické klávesnici.

NumPad7 103

Klávesa 7 na numerické klávesnici.

NumPad8 104

Klávesa 8 na numerické klávesnici.

NumPad9 105

Klávesa 9 na numerické klávesnici.

Multiply 106

Klávesa násobení (násobení na numerické klávesnici)

Add 107

Klávesa Add (sčítání na numerické klávesnici).

Separator 108

Klávesa Oddělovač.

Subtract 109

Odečítání klíče (odčítání na numerické klávesnici)

Decimal 110

Desetinná klávesa (desítková klávesa na numerické klávesnici).

Divide 111

Klíč Divide (klávesa dělení na numerické klávesnici).

F1 112

Klávesa F1.

F2 113

Klávesa F2.

F3 114

Klávesa F3.

F4 115

Klávesa F4.

F5 116

Klávesa F5.

F6 117

Klávesa F6.

F7 118

Klávesa F7.

F8 119

Klávesa F8.

F9 120

Klávesa F9.

F10 121

Klávesa F10.

F11 122

Klávesa F11.

F12 123

Klávesa F12.

F13 124

Klávesa F13.

F14 125

Klávesa F14.

F15 126

Klávesa F15.

F16 127

Klávesa F16.

F17 128

Klávesa F17.

F18 129

Klávesa F18.

F19 130

Klávesa F19.

F20 131

Klávesa F20.

F21 132

Klávesa F21.

F22 133

Klávesa F22.

F23 134

Klávesa F23.

F24 135

Klávesa F24.

BrowserBack 166

Klávesa Zpět prohlížeče.

BrowserForward 167

Klávesa Forward v prohlížeči.

BrowserRefresh 168

Obnovovací klíč prohlížeče.

BrowserStop 169

Klávesa Stop prohlížeče.

BrowserSearch 170

Klíč vyhledávání v prohlížeči.

BrowserFavorites 171

Klíč Oblíbené položky prohlížeče.

BrowserHome 172

Domovská klávesa prohlížeče.

VolumeMute 173

Ztlumení hlasitosti (Microsoft přirozené klávesnice).

VolumeDown 174

Klávesa Pro snížení hlasitosti (Microsoft přirozené klávesnici).

VolumeUp 175

Klávesa Pro zvýšení hlasitosti (Microsoft přirozené klávesnice).

MediaNext 176

Klávesa Media Next Track.

MediaPrevious 177

Klávesa Media Previous Track.

MediaStop 178

Klávesa Stop média.

MediaPlay 179

Klávesa Přehrát/Pozastavit multimédia

LaunchMail 180

Klávesa Start Mail (Microsoft Natural Keyboard).

LaunchMediaSelect 181

Klávesa Select Media (Microsoft Natural Keyboard).

LaunchApp1 182

Klávesa Start Application 1 (Microsoft Natural Keyboard).

LaunchApp2 183

Klávesa Start Application 2 (Microsoft Natural Keyboard).

Oem1 186

Klíč OEM 1 (specifický pro OEM).

OemPlus 187

Klávesa OEM Plus na libovolné klávesnici země/oblasti

OemComma 188

Klávesa Čárka OEM na libovolné klávesnici země/oblasti

OemMinus 189

Klávesa OEM Minus na libovolné klávesnici země/oblasti.

OemPeriod 190

Klávesa Období OEM na libovolné klávesnici země/oblasti.

Oem2 191

Klíč OEM 2 (specifický pro OEM).

Oem3 192

Klíč OEM 3 (specifický pro OEM).

Oem4 219

Klíč OEM 4 (specifický pro OEM).

Oem5 220

OEM 5 (specifické pro OEM).

Oem6 221

Klíč OEM 6 (specifický pro OEM).

Oem7 222

Klíč OEM 7 (specifický pro OEM).

Oem8 223

Klíč OEM 8 (specifický pro OEM).

Oem102 226

Klíč OEM 102 (specifický pro OEM).

Process 229

Klíč PROCESU editoru IME.

Packet 231

Klíč PACKET (slouží k předávání znaků Unicode pomocí klávesových úhošťů).

Attention 246

Klíč ATTN.

CrSel 247

Klávesa CRSEL (CURSOR SELECT)

ExSel 248

Klíč EXSEL (EXTEND SELECTION).

EraseEndOfFile 249

Klíč ERASE EOF.

Play 250

Klávesa PLAY.

Zoom 251

Klávesa ZOOM.

NoName 252

Konstanta vyhrazená pro budoucí použití.

Pa1 253

Klíč PA1.

OemClear 254

Klíč CLEAR (specifický pro OEM).

Příklady

Následující příklad používá ConsoleKey výčet k označení uživatele, který klávesu uživatel stiskl.

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.HasFlag(ConsoleModifiers.Alt)) {
            output.Append(", together with " + ConsoleModifiers.Alt.ToString());
            modifiers = true;
         }
         if (input.Modifiers.HasFlag(ConsoleModifiers.Control))
         {
            if (modifiers) {
               output.Append(" and ");
            }
            else {
               output.Append(", together with ");
               modifiers = true;
            }
            output.Append(ConsoleModifiers.Control.ToString());
         }
         if (input.Modifiers.HasFlag(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, together with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed D.
//
//       Press a key, together with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed X, together with Shift.
//
//       Press a key, together with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed L, together with Control and Shift.
//
//       Press a key, together with Alt, Ctrl, or Shift.
//       Press Esc to exit.
//       You pressed P, together with Alt and Control and Shift.
//
//       Press a key, together 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.

Poznámky

Výčet ConsoleKey se obvykle používá ve struktuře nfo, která je vrácena metodou Console.ReadKey k označení, která klávesa na konzole byla stisknuta.

Platí pro