santijlm
❔ Stop a loop when a key is pressed
I tried this:
bool loop = true;
while (loop)
{
//Loop Stuff
if (IsKeyDown(myKey))
{
loop = false;
}
}
and this
while (loop)
{
//Loop Stuff
if (IsKeyDown(myKey))
{
break;
}
}
But they didn't work.
Also, saw this in StackOverflow:
while(!Console.KeyAvailable)
{
//do work
}
But apparently that won't work unless I use a Console Application.
A few days ago I tried the code in this StackOverflow post, but I see it too complicated, and don't understand anything. ¿Could someone explain? I hate the idea of just pasting a piece of code I don't even understand.20 replies