Keyboard problem
in
Programming Questions
•
2 months ago
Hello!
Why can't I press more than one button at the same time?
If I press the UP button, the player goes up (y--)
If I press the LEFT button, the player goes left (x--)
But if I press them both the player does not go diagonal, but only in one direction.
This is the buttons code:
Why can't I press more than one button at the same time?
If I press the UP button, the player goes up (y--)
If I press the LEFT button, the player goes left (x--)
But if I press them both the player does not go diagonal, but only in one direction.
This is the buttons code:
- if (keyPressed)
- {
- if (keyCode == LEFT)
- {
- x--;
- }
- if (keyCode == UP)
- {
- y--;
- }
- }
1