This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.

The First Task - Responding to Keystrokes [April 7, 2011, 2:19 p.m.]


This task is here to help you decide whether the material will be the right level for you or not.  Here's what I'd like you to do before joining the course:

Set up an HTML file that loads a separate Javascript file.  Write some code to detect when the user presses a key on the keyboard. Whenever the user presses one of the arrow keys, display a message on the page (e.g. display "You pressed the up arrow.").

(Hint: One easy way, but maybe not the best way, is to attach an onkeydown or onkeyup handler to the body element of the page. Which would you choose, onkeydown or onkeyup? Why?)

If you already know how to do this, or if you think you can figure it out, then this course will be at the right level for you. If the task sounds too hard, then you should probably start with an introductory Javascript course before joining this group.

Doing this task will help you learn the basics of Javascript, as well as providing a basic input system that you can re-use again and again in different game projects. (After all, nearly every game involves some kind of keyboard input!)

If you don't happen to have a webserver where you can host your HTML and JS files for this task, don't worry -- you can just develop the files on your hard drive, using "File -> Open" to load the HTML page in your web browser.