Workshop › Mario-style Platformer › Step 16 of 37
Good platformers let you choose the height: hold the button for a full jump, tap it for a short hop. When the button is
released while still rising fast, the upward speed is cut to CUT.
```js
const CUT = -4 // letting go early caps the upward speed at this
function endJump() {
if (player.vy < CUT) player.vy = CUT
}
if (event.key === ' ' || event.key === 'ArrowUp') endJump()
```vy is below -4 (more negative); then it is set to -4.keyup of Space or up calls it.JUMP write CUT.jump, leave an empty line and write endJump.keyup listener, under keys[event.key] = false, write the endJump line.Skills: Keyboard and mouse input, Velocity and gravity
← Bump your head A few frames of grace →