I have the following lines of code in my Console Application in C#:
public static bool ReadKey(int key)
{
/* Is the key represented by `key` pressed? */
}
How am I able to retrieve the right keyboard key?
I have the following lines of code in my Console Application in C#:
public static bool ReadKey(int key)
{
/* Is the key represented by `key` pressed? */
}
How am I able to retrieve the right keyboard key?
If you're application needs to be executing without pause and in that execution you need to check if key is pressed then: You can't do that in c# console application.
Take a look into first answer in this question. Same thing, you just need to modify it to support all needed keys instead of just arrow keys
C# arrow key input for a console app
or
If the case is that you need to wait for user input, the simplest solution is Console.ReadKey();