Workshop › Mario-style Platformer › Step 14 of 37
A jump is just an upward speed: vy = JUMP, a negative number. Gravity does the rest: it slows the rise, turns it into a
fall and lands the player. You may only jump while standing on something.
```js
const JUMP = -11.5
function jump() {
if (player.grounded) {
player.vy = JUMP
}
}
if ((event.key === ' ' || event.key === 'ArrowUp') && !event.repeat) jump()
```JUMP is negative because up is negative y.jump only works when grounded.event.repeat is true for the automatic repeats of a held key, so holding the key does
not jump again and again.FRICTION write JUMP.keydown listener write jump, with an empty line after it.keydown listener, under keys[event.key] = true, write the jump line.Skills: Keyboard and mouse input, Velocity and gravity