Command Palette

Search for a command to run...

Hectal
Phase 8: Interaction
3D Web · Exercise 3 of 4 PreviousNext
Intermediate

Give the viewer a keyboard

#host can take focus but ignores keys. In its keydown handler make ArrowLeft and ArrowRight turn cube by 15 degrees on rotation.y (left is minus) and handle nothing else.

Tab must not be cancelled and Ctrl with an arrow must be ignored: call preventDefault() only for keys you handled.

What Check tests

  1. ArrowRight turns the cube by 15 degrees
  2. ArrowLeft turns it back
  3. Tab is left alone
  4. Ctrl and an arrow is ignored

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.