Workshop › Typing Rain › Step 30 of 33
Each key is a dark box with its letter in the middle. forEach goes over the rows, and a for loop over the letters
of each row.
```js
ctx.textAlign = 'center'
ctx.font = 'bold 18px sans-serif'
ROWS.forEach((keys, row) => {
for (let i = 0; i < keys.length; i++) {
const k = keyRect(row, i)
ctx.fillStyle = '#1e293b'
ctx.fillRect(k.x, k.y, KEY_W, KEY_H)
ctx.fillStyle = '#e2e8f0'
ctx.fillText(keys[i], k.x + KEY_W / 2, k.y + 23)
}
})
```ROWS.forEach((keys, row) => ...) runs once per row: keys is its text, row its number.keys[i] is its ith letter and keys.length how many there are.KEY_W / 2), with its baseline 23 pixels from the top.At the end of draw, after the game over block, leave an empty line and write the keyboard lines.
Skills: Drawing on a canvas, Loops
← Where the keys go Light up the next key →