Skip to content

Console.ReadKey

Console.ReadKey reads a single key press without waiting for Enter.

Console.Write("Press any key: ");
var key = Console.ReadKey();
Console.WriteLine($"\nYou pressed: {key.KeyChar}");
Terminal window
dotnet run
Terminal window
Press any key: A
You pressed: A