mercredi 1 novembre 2017

Console.KeyAvailable isn't being triggered

I am wanting to detect if any key is being pressed but as far as I can tell the if statement isn't being triggered otherwise the program would shut down due to Enviroment.Exit(0).

public static int GameLoop()
        {
            while(true)
            {
                if(Console.KeyAvailable == true)
                {
                    Environment.Exit(0); //test to see if being used
                    Player.KeyPressed = Console.ReadKey().KeyChar;
                    Player.Movement();
                }

                Console.WriteLine("working");

GameLoop() is being called because Console.WriteLine("working") is being executed. Any Ideas as to why Console.KeyAvailable == true isn't being met on key press? Thanks!

Console.KeyAvailable MSDN

Aucun commentaire:

Enregistrer un commentaire