Graphic JavaScript


Back to index
Keyboard Input

Your browser does not support the HTML5 canvas tag.

Click here for larger version!

ASSIGNMENT:

First of all try typing some words into this applet and then find out what happens when you press the backspace, escape, or enter keys. Inspect the code carefully to see how all this works.

Alter the code as follows:

  1. Pressing the ENTER key changes the color of the background. Have your script cycle between at least five colors for the background.
  2. Once the length of the input string reaches 20 characters have it automatically clear.
  3. Pressing the ESCAPE key changes the message to OUT TO LUNCH
  4. Pressing the BACKSPACE key changes the input to all lowercase. HINT: var res = str.toLowerCase();