HTML and CSS Reference
Listing 7.12. game.js—Player ship interactivity
Note that you can test your new blue ship by commenting out uncreated objects in Game
to suppress errors. Be careful to check your browser's console log to make sure no errors
accidentally fire. If you choose to tinker with your game, make sure to repair it to look like
our previous listings before proceeding. You may need to suppress any errors from missing
objects to make the following snippets work too.
Step 6: Capture keyboard and mouse controls
Many tutorials depend on jQuery or another library to create keyboard bindings. Most key-
board keys are consistent enough between browsers these days that you don't need a lib-
rary. You can safely implement arrow keys, a spacebar, letters, mouse movement, and a
mouse click at the least, which is what you'll do in the next listing by replacing your exist-
ing Ctrl object.