Workshop › Tetris-style Blocks › Step 30 of 32
Space drops the piece to the bottom at once and locks it. Dropping on purpose is rewarded: 1 point per row with the Down arrow, 2 per row with Space.
```js
function hardDrop() {
while (tryMove(0, 1)) score += 2
lock()
}
if (event.key === 'ArrowDown') {
if (tryMove(0, 1)) score += 1
}
if (event.key === ' ') hardDrop()
```while (condition) ... repeats as long as the condition is true. Here the condition itself moves the piece: each
successful tryMove(0, 1) adds 2 points, and the first refusal ends the loop. Then lock().hardDrop under softDrop.ArrowDown line with the block and add the Space line under it.Skills: Keyboard and mouse input, Loops
← The next piece The ghost piece →