Pressing a key and then executing another key
1 answer
You can implement it without a timer, for example these codes:
static void Main(string[] args)
{
var time = 3;
char myKey = 'q';
// do some things ...
var key = Console.ReadKey().KeyChar;
if (key == myKey)
{
bool ok = true;
for (int count = 0; count < time; count++)
{
key = Console.ReadKey().KeyChar;
if (key != myKey)
{
ok = false;
break;
}
}
if (ok)
{
// do my work
}
else
{
// Do some else works ...
}
}
else
{
// Do some else works ...
}
Console.ReadKey();
}
+1
source to share