Why dont you use events?
For example:
YourKeyboard W is down: YourSpaceship move forward x pixels
YourKeyboard a is down: YourSpaceship rotate x degrees counter-clockwise
Develop games in your browser. Powerful, performant & highly capable.