Workshop › Hangman › Step 32 of 36
A loop over the 26 letters draws each key: a light box from keyRect(i) with its letter centered on it.
```js
function draw() {
// ...
for (let i = 0; i < LETTERS.length; i++) {
const letter = LETTERS[i]
const k = keyRect(i)
ctx.fillStyle = '#e7e5e4'
ctx.fillRect(k.x, k.y, KEY_W, KEY_H)
ctx.fillStyle = '#1f2937'
ctx.font = 'bold 18px sans-serif'
ctx.fillText(letter, k.x + KEY_W / 2, k.y + 24)
}
}
```i = 0 to 25; LETTERS[i] is the i-th letter.k is the key's corner. The box is KEY_W × KEY_H there.textAlign is still 'center') at the middle of the key, 24 pixels down.In draw, at the very end (under the end-message block, above the closing }), leave an empty line and write the
loop. Press Run.
Skills: Drawing on a canvas, Loops
← Where each key goes Center the last row →