How to set a value for ConsoleKeyInfo

2.7k Views Asked by At

I have made little game in which player can move trough a dungeon. But now I want to make the game play itself. But I cant make my bot to press buttons.

ConsoleKeyInfo cki;

 cki = Console.ReadKey();
 cki = Game.Bot.Move();

 public static ConsoleKeyInfo Move(Random rnd)
            {
                ConsoleKeyInfo cki;
                cki.Key = ConsoleKey.RightArrow;
                return cki;
            }

But this give me an error.

I just want to move my character somehow. P.S. I founded this but cant test it because I don't know the char for arrows keys

ConsoleKeyInfo cki=new ConsoleKeyInfo('', ConsoleKey.LeftArrow, false, false, false);
1

There are 1 best solutions below

0
Fi Jeleva On BEST ANSWER

I fount what I was looking for.

ConsoleKeyInfo cki = new ConsoleKeyInfo((char)ConsoleKey.RightArrow, ConsoleKey.RightArrow, false, false, false);

This line gives me the button pressed :)