Workshop › Tetris-style Blocks › Step 14 of 32
Turning is like moving: work out the turned shape, and use it only if it fits. The Up arrow or x turns the piece.
```js
function tryRotate() {
const turned = rotate(piece.shape)
if (!fits(turned, piece.x, piece.y)) return false
piece.shape = turned
return true
}
if (event.key === 'ArrowUp' || event.key === 'x') tryRotate()
```turned is a new, rotated matrix; piece is not touched yet.|| means "or": the Up arrow or x.tryRotate under tryMove.ArrowRight line, write the ArrowUp line.Skills: Keyboard and mouse input, Collision detection