Workshop › Hangman › Step 11 of 36
Now the player guesses: when a key goes down, we turn its name into a capital letter and guess it.
```js
document.addEventListener('keydown', (event) => {
const letter = event.key.toUpperCase()
guess(letter)
})
```addEventListener('keydown', ...) runs the function each time a key goes down.event.key is the key's name: 'a' for the A key..toUpperCase() makes it a capital, 'A', like the words.Write the listener under the guess function, with an empty line between. Press Run, click the game once and
type some letters.
Skills: Keyboard and mouse input
← A guess Only letters count →