Workshop › Breakout › Step 26 of 39
Every frame, while an arrow key is held, the paddle moves 7 pixels. Then clamp keeps it on the screen.
```js
if (keys.ArrowLeft) paddle.x -= 7
if (keys.ArrowRight) paddle.x += 7
paddle.x = clamp(paddle.x, 0, canvas.width - PADDLE_W)
```keys.ArrowLeft is true while the left arrow is held; -= 7 subtracts 7.undefined, which counts as false.clamp keeps the paddle between 0 and 400.Write the three lines at the very top of update, above the serve block, followed by an empty line.
Skills: Keyboard and mouse input
← Remember which keys are held Three lives →