C # console application onKeyUp

I am trying to make a small game in a console application in Visual Studio. I want to discover when I released the key. Because now that I release the key, it remains β€œtrue” until I hit any other key.

Here is my code

while (true) { keyInfo = Console.ReadKey(); if(keyInfo.Key == ConsoleKey.RightArrow) { rightPressed = true; } else { rightPressed = false; } } 

Does anyone have a solution?

+5
source share

Source: https://habr.com/ru/post/1247917/


All Articles