Workshop › Pool › Step 8 of 33
The left and right arrows turn the aim a little each press (0.035 radians, about 2 degrees). The browser's own action for these keys (scrolling) is stopped.
```js
document.addEventListener('keydown', (event) => {
if (event.key === 'ArrowLeft') aim -= 0.035
else if (event.key === 'ArrowRight') aim += 0.035
else return
event.preventDefault()
})
```return at once. Only the game's keys reach preventDefault().Above function draw() { write the listener, with an empty line after it. Run, click the game and use the arrows.
Skills: Keyboard and mouse input
← An aim line A shot is a velocity →