In C#, Console.ReadKey waits for a single key and returns a ConsoleKeyInfo value with the key, character (if any), and modifier keys.
Pass intercept: true (or true) so the key is not echoed on the screen—useful for “Press any key…” pauses and simple menus. Unlike ReadLine, you do not need to press Enter for letter keys.
This is a static member of System.Console. You call it with the type name, such as Console.ReadKey(...). Console is the everyday API for reading from standard input and writing to standard output in C# console apps.
Syntax
Call ReadKey or ReadKey(true) and inspect Key or KeyChar.
C#
ConsoleKeyInfo info = Console.ReadKey();
ConsoleKeyInfo hidden = Console.ReadKey(true);
Call
What it does
Console.ReadKey()
Reads a key and echoes it.
Console.ReadKey(true)
Reads a key without echoing (intercept).
Some keys (arrows, function keys) have KeyChar of \\0. Check ConsoleKey for those.
Library declarations
C#
public static ConsoleKeyInfo ReadKey();
public static ConsoleKeyInfo ReadKey(bool intercept);
Parameters
Parameter
Description
intercept
Optional. When true, the key is not displayed on the console.
Return Value
Return Value
Description
ConsoleKeyInfo
Describes the key (Key), character (KeyChar), and modifiers.
C# Examples
Example 1 — Press Any Key to Continue
Show a pause message and wait with intercept so the key is not echoed.
C#
using System;
class Program {
static void Main() {
Console.WriteLine("Working...");
Console.WriteLine("Press any key to continue...");
Console.ReadKey(true);
Console.WriteLine("Thanks!");
}
}
Output
Working...
Press any key to continue...
Thanks!
How It Works
Intercept true. The pressed key does not appear between the messages.
Sample pause. Output jumps to Thanks after a key (key itself not shown).
Blocking wait. Main stops until a key arrives.
Simple UX. Common pattern at the end of small demos.
Example 2 — Choose 1 or 2 With ReadKey
Build a tiny menu that reacts to a digit key.
C#
using System;
class Program {
static void Main() {
Console.WriteLine("1) Greet");
Console.WriteLine("2) Exit");
Console.Write("Choice: ");
ConsoleKeyInfo info = Console.ReadKey(true);
Console.WriteLine(info.KeyChar);
if (info.KeyChar == '1') {
Console.WriteLine("Hello!");
} else {
Console.WriteLine("Goodbye");
}
}
}
Output
1) Greet
2) Exit
Choice: 1
Hello!
How It Works
Hidden then print. Intercept hides the key; we print KeyChar ourselves.
Sample choice. sample output shows selecting 1.
No Enter needed. The digit key alone is enough.
Branch. Compare KeyChar (or Key) to decide the path.
Example 3 — Show ConsoleKey for Arrow Keys
Print the Key enum when KeyChar is not useful.
C#
using System;
class Program {
static void Main() {
Console.WriteLine("Press an arrow key...");
ConsoleKeyInfo info = Console.ReadKey(true);
Console.WriteLine("Key = " + info.Key);
Console.WriteLine("KeyChar empty? " + (info.KeyChar == '\0'));
}
}
Output
Press an arrow key...
Key = RightArrow
KeyChar empty? True
How It Works
Special keys. Arrows often have no printable KeyChar.
Use Key. The ConsoleKey enum names the physical key.
Sample RightArrow. Output assumes the right arrow was pressed.
Intercept again. Avoids odd echo for non-character keys.
Frequently Asked Questions
When true, the key is read but not shown on the screen.
Usually no for letter and digit keys. ReadKey returns after one key press.
A small struct with Key, KeyChar, and modifier information.
ReadKey is one key. ReadLine is a whole line ending with Enter.
Console key APIs expect an interactive console; redirected or unsupported hosts may throw or behave differently.