C# Key Down stops firing after right arrow key pressed

103 Views Asked by At

My team and I made a game version of Snake, and everything works well except after I push the right arrow key, then the key events stop firing. I have tried setting Keyboard.Focus and other focus methods, but it doesn't work.

Our project is on github at: csis2530, look for bbarke.

I don't know why the key down event stops working after the right arrow key has been pressed.

I hope someone could help us.

1

There are 1 best solutions below

0
On BEST ANSWER

I fixed the gui by ensuring that the GameWindow has the focus and only the GameWindow has the focus. This is what you do:

Click on the New Game button, go to its property and search for "Focusable". Then UNcheck the Focusable checkbox. Do this for the combobox (the one that has the levels), the high score button, and the apples eaten label, and everything else EXCEPT for the Game Window. Make sure that the GameWindow has the focus and make sure that its Focusable is checked.

I noticed that when I push on the arrow keys, the combo box would change. This is due to the focus from the GameWindow being taken away by the combo box.

So make sure that only the GameWindow has the Focusable property checked.