detect what keys are currently held down? (Multiple keys held down at once)
in
Programming Questions
•
2 years ago
So I need a way to detect what keys are currently pressed down. In my game program I need to move an object in 8 directions:
Up if W key is pressed
Down if S key is pressed
Left if A key is pressed
Right if D key is pressed
But, if two keys are pressed, I need it to move diagonally. keyPressed and KeyReleased stuff isn't doing it for me, because it can really only handle one key at a time, and it's just not suitable for game controls.
Up if W key is pressed
Down if S key is pressed
Left if A key is pressed
Right if D key is pressed
But, if two keys are pressed, I need it to move diagonally. keyPressed and KeyReleased stuff isn't doing it for me, because it can really only handle one key at a time, and it's just not suitable for game controls.
2