Workshop › Endless Runner › Step 17 of 19

Which keys are down?

What we are doing

To duck, we need to know whether the down arrow is held right now, not just when it was pressed. A keys object remembers every key that is down.

```js
const keys = {}

  keys[event.key] = true

  keys[event.key] = false
```

What it means

Your turn

  1. Under best, write const keys = {}.
  2. Make the key lines the first lines of the keydown and keyup listeners.

Skills: Keyboard and mouse input

All steps

  1. The ground
  2. The runner
  3. Draw again and again
  4. Gravity
  5. Jump
  6. Short hops
  7. Tap to jump
  8. Things that come at you
  9. Cacti keep coming
  10. Wait for the start
  11. Crash
  12. Try again
  13. Faster and faster
  14. Remember the best run
  15. The score counter
  16. Birds
  17. Which keys are down?
  18. Duck
  19. Build it yourself: jump buffering