Workshop › Breakout › Step 25 of 39
To steer the paddle with the arrow keys, we note which keys are held down: keydown writes true, keyup writes
false.
```js
const keys = {}
document.addEventListener('keydown', (event) => {
keys[event.key] = true
if (event.key === ' ') launch()
})
document.addEventListener('keyup', (event) => {
keys[event.key] = false
})
```keys starts as an empty object. keys[event.key] = true sets the field named after the key, e.g. keys.ArrowLeft.keyup fires when a key is released; then the field becomes false.keys is a const, but its contents can still change.let state ... write const keys = {}.keydown listener, add keys[event.key] = true as its first line.keyup listener.Skills: Keyboard and mouse input
← Click or press Space Steer with the arrow keys →