ConsoleKey Enumeráció
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Megadja a konzol szabványos kulcsait.
public enum class ConsoleKey
public enum ConsoleKey
[System.Serializable]
public enum ConsoleKey
type ConsoleKey =
[<System.Serializable>]
type ConsoleKey =
Public Enum ConsoleKey
- Öröklődés
- Attribútumok
Mezők
| Name | Érték | Description |
|---|---|---|
| None | 0 | Nincs lenyomva kulcs. |
| Backspace | 8 | A BACKSPACE kulcs. |
| Tab | 9 | A TAB billentyű. |
| Clear | 12 | A CLEAR kulcs. |
| Enter | 13 | Az ENTER billentyű. |
| Pause | 19 | A PAUSE billentyű. |
| Escape | 27 | Az ESC (ESCAPE) kulcs. |
| Spacebar | 32 | A SZÓKÖZ billentyű. |
| PageUp | 33 | A PAGE UP billentyű. |
| PageDown | 34 | A PAGE DOWN billentyű. |
| End | 35 | A END billentyű. |
| Home | 36 | A HOME billentyű. |
| LeftArrow | 37 | A BALRA nyílbillentyű. |
| UpArrow | 38 | A FEL nyílbillentyű. |
| RightArrow | 39 | A JOBBRA nyílbillentyű. |
| DownArrow | 40 | A LE nyílbillentyű. |
| Select | 41 | A SELECT billentyű. |
| 42 | A PRINT billentyű. |
|
| Execute | 43 | Az EXECUTE kulcs. |
| PrintScreen | 44 | A PRINT SCREEN billentyű. |
| Insert | 45 | Az INS (INSERT) kulcs. |
| Delete | 46 | A DEL (DELETE) kulcs. |
| Help | 47 | A HELP billentyű. |
| D0 | 48 | A 0 billentyű. |
| D1 | 49 | Az 1 billentyű. |
| D2 | 50 | A két kulcs. |
| D3 | 51 | A három kulcs. |
| D4 | 52 | A 4 billentyű. |
| D5 | 53 | Az 5 billentyű. |
| D6 | 54 | A 6-os kulcs. |
| D7 | 55 | A 7 kulcs. |
| D8 | 56 | A 8-at. |
| D9 | 57 | A 9 billentyű. |
| A | 65 | Az A kulcs. |
| B | 66 | A B billentyű. |
| C | 67 | A C billentyű. |
| D | 68 | A D billentyű. |
| E | 69 | Az E billentyű. |
| F | 70 | Az F billentyű. |
| G | 71 | A G billentyű. |
| H | 72 | A H billentyű. |
| I | 73 | Az I kulcs. |
| J | 74 | A J billentyű. |
| K | 75 | A K billentyű. |
| L | 76 | Az L billentyű. |
| M | 77 | Az M billentyű. |
| N | 78 | Az N billentyű. |
| O | 79 | Az O billentyű. |
| P | 80 | A P billentyű. |
| Q | 81 | A Q-kulcs. |
| R | 82 | Az R billentyű. |
| S | 83 | Az S kulcs. |
| T | 84 | A T billentyű. |
| U | 85 | Az U billentyű. |
| V | 86 | A V kulcs. |
| W | 87 | A W billentyű. |
| X | 88 | Az X billentyű. |
| Y | 89 | Az Y billentyű. |
| Z | 90 | A Z billentyű. |
| LeftWindows | 91 | A bal Windows billentyű (Microsoft Természetes billentyűzet). |
| RightWindows | 92 | A jobb Windows billentyű (Microsoft Természetes billentyűzet). |
| Applications | 93 | Az alkalmazáskulcs (Microsoft természetes billentyűzet). |
| Sleep | 95 | A számítógép alvó kulcsa. |
| NumPad0 | 96 | A numerikus billentyűzet 0 kulcsa. |
| NumPad1 | 97 | Az 1 billentyű a numerikus billentyűzeten. |
| NumPad2 | 98 | A numerikus billentyűzet 2 kulcsa. |
| NumPad3 | 99 | A numerikus billentyűzet 3 kulcsa. |
| NumPad4 | 100 | A numerikus billentyűzet 4 kulcsa. |
| NumPad5 | 101 | Az 5 billentyű a numerikus billentyűzeten. |
| NumPad6 | 102 | A numerikus billentyűzet 6 kulcsa. |
| NumPad7 | 103 | A 7 billentyű a numerikus billentyűzeten. |
| NumPad8 | 104 | A numerikus billentyűzet 8 kulcsa. |
| NumPad9 | 105 | A numerikus billentyűzet 9 kulcsa. |
| Multiply | 106 | A szorzási kulcs (a számbillentyűzet szorzási kulcsa). |
| Add | 107 | A Hozzáadás billentyű (a számbillentyűzeten lévő összeadási kulcs). |
| Separator | 108 | Az elválasztó kulcs. |
| Subtract | 109 | A kivonási kulcs (a számbillentyűzet kivonási kulcsa). |
| Decimal | 110 | A decimális kulcs (a numerikus billentyűzeten lévő tizedesjel). |
| Divide | 111 | Az Osztókulcs (a numerikus billentyűzet osztáskulcsa). |
| F1 | 112 | Az F1 billentyű. |
| F2 | 113 | Az F2 billentyű. |
| F3 | 114 | Az F3 billentyű. |
| F4 | 115 | Az F4 billentyű. |
| F5 | 116 | Az F5 billentyű. |
| F6 | 117 | Az F6 billentyű. |
| F7 | 118 | Az F7 billentyű. |
| F8 | 119 | Az F8 billentyű. |
| F9 | 120 | Az F9 billentyű. |
| F10 | 121 | Az F10 billentyű. |
| F11 | 122 | Az F11 billentyű. |
| F12 | 123 | Az F12 billentyű. |
| F13 | 124 | Az F13 billentyű. |
| F14 | 125 | Az F14 billentyű. |
| F15 | 126 | Az F15 billentyű. |
| F16 | 127 | Az F16 billentyű. |
| F17 | 128 | Az F17 billentyű. |
| F18 | 129 | Az F18 billentyű. |
| F19 | 130 | Az F19 billentyű. |
| F20 | 131 | Az F20 billentyű. |
| F21 | 132 | Az F21 billentyű. |
| F22 | 133 | Az F22 billentyű. |
| F23 | 134 | Az F23 billentyű. |
| F24 | 135 | Az F24 billentyű. |
| BrowserBack | 166 | A böngésző visszakulcsa. |
| BrowserForward | 167 | A Böngésző továbbítása kulcs. |
| BrowserRefresh | 168 | A böngésző frissítési kulcsa. |
| BrowserStop | 169 | A böngésző leállítási kulcsa. |
| BrowserSearch | 170 | A böngésző keresési kulcsa. |
| BrowserFavorites | 171 | A Böngésző kedvencek kulcsa. |
| BrowserHome | 172 | A böngésző kezdőlapja. |
| VolumeMute | 173 | A Hangerő elnémítása billentyű (Microsoft Természetes billentyűzet). |
| VolumeDown | 174 | A Hangerőszabályzó billentyű (Microsoft Természetes billentyűzet). |
| VolumeUp | 175 | A Hangerő növelése billentyű (Microsoft Természetes billentyűzet). |
| MediaNext | 176 | A Media Next Track billentyű. |
| MediaPrevious | 177 | A Media Previous Track billentyű. |
| MediaStop | 178 | A Media Stop billentyű. |
| MediaPlay | 179 | A Media Play/Pause billentyű. |
| LaunchMail | 180 | A Start Mail billentyű (Microsoft Természetes billentyűzet). |
| LaunchMediaSelect | 181 | A Média kiválasztása billentyű (Microsoft Természetes billentyűzet). |
| LaunchApp1 | 182 | Az Alkalmazás indítása 1 billentyű (Microsoft Természetes billentyűzet). |
| LaunchApp2 | 183 | A Start Application 2 billentyű (Microsoft Természetes billentyűzet). |
| Oem1 | 186 | Az OEM 1 kulcs (oem-specifikus). |
| OemPlus | 187 | Az OEM Plus billentyű bármely ország/régió billentyűzetén. |
| OemComma | 188 | Az OEM-vessző kulcsa bármely ország-régió billentyűzetén. |
| OemMinus | 189 | Az OEM Mínusz billentyű bármely ország/régió billentyűzetén. |
| OemPeriod | 190 | Az OEM-időszak billentyű bármely ország/régió billentyűzetén. |
| Oem2 | 191 | Az OEM 2 kulcs (oem-specifikus). |
| Oem3 | 192 | Az OEM 3 kulcs (OEM-specifikus). |
| Oem4 | 219 | Az OEM 4 kulcs (oem-specifikus). |
| Oem5 | 220 | Az OEM 5 (OEM-specifikus). |
| Oem6 | 221 | Az OEM 6 kulcs (OEM-specifikus). |
| Oem7 | 222 | Az OEM 7 kulcs (OEM-specifikus). |
| Oem8 | 223 | Az OEM 8 kulcs (oem-specifikus). |
| Oem102 | 226 | Az OEM 102 kulcs (oem-specifikus). |
| Process | 229 | Az IME PROCESS-kulcs. |
| Packet | 231 | A PACKET kulcs (Unicode-karakterek billentyűleütésekkel való átadására szolgál). |
| Attention | 246 | Az ATTN-kulcs. |
| CrSel | 247 | A CRSEL (CURSOR SELECT) billentyű. |
| ExSel | 248 | Az EXSEL (EXTEND SELECTION) billentyű. |
| EraseEndOfFile | 249 | A ERASE EOF billentyű. |
| Play | 250 | A PLAY billentyű. |
| Zoom | 251 | A ZOOM billentyű. |
| NoName | 252 | A jövőbeli használatra fenntartott állandó. |
| Pa1 | 253 | A PA1 billentyű. |
| OemClear | 254 | A CLEAR kulcs (oem-specifikus). |
Példák
Az alábbi példa az ConsoleKey enumerálás használatával jelzi a felhasználónak, hogy melyik kulcsot lenyomta a felhasználó.
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.
Megjegyzések
Az ConsoleKey enumerálást általában az nfo struktúrában használják, amelyet a Console.ReadKey metódus a konzolon található kulcs lenyomásának jelzésére ad vissza.