I want to break or pause a do/while
loop if a user presses a key in the console. I have tried ReadLine
or ReadKey
but then my program stops and it is waiting for input, but I only want my program to stop after user input.
My code:
do
{
//do some code until user input
Console.WriteLine("for settings: Press 's'");
ConsoleKeyInfo cki;
cki = Console.ReadKey(); // here the program stops and waits for input but I don't want it
if (cki.Key.ToString() == "S")
{
Console.WriteLine("SETTINGS");
}
} while (true);