Workshop › Flappy-style Bird › Step 9 of 30
Now the player flaps: with Space, the Up arrow, or a click or tap on the game. One behavior (flap), many triggers.
```js
document.addEventListener('keydown', (event) => {
if (event.key === ' ' || event.key === 'ArrowUp') flap()
})
canvas.addEventListener('pointerdown', flap)
```keydown fires when a key goes down, anywhere on the page (document).event.key is the key's name: ' ' for Space, 'ArrowUp' for the Up arrow. || means "or".pointerdown fires when the canvas is clicked or touched; it calls flap directly.Write the lines under flap, after an empty line. Run, click the game once, then press Space.
Skills: Keyboard and mouse input
← A flap Wait for the first flap →