BIT 116 – Scripting

Handling Keyboard Input


Part 1: Uber-Basic keyboard Handling

Create a P (paragraph) element, and set up your code so that when any key is pressed, that element's text will be changed to some other text ("You've pressed a key" is a good string to change the element to :)  )

Part 2: Which key?

Figure out (using that other page) the key that corresponds to the 'r' key, and to the 'g' key.  When the 'r' key is pressed, change some text to be red.  When the 'g' key is pressed, change it to be green.

Part 3: Which key, with modifier keys

Extend the previous example, so that if the SHIFT key is down, you'll make the text BRIGHT red/green.  Note that the text color shouldn't change if you only press the SHIFT key.

Part 4: Incorporate this feature into your game

If applicable, add this feature into your game (A4)