Workshop › Endless Runner › Step 18 of 19
Holding the down arrow on the ground makes the runner shorter, low enough to pass under a bird. While ducking it cannot jump.
```js
const DUCK_H = 26
// Duck only on the ground; keep the feet in place when the height changes.
const h = keys.ArrowDown && onGround() ? DUCK_H : STAND_H
runner.y += runner.h - h
runner.h = h
if (onGround() && runner.h === STAND_H) runner.vy = JUMP
```h is the height the runner should have this frame: short while the down arrow is held on the ground.runner.y += runner.h - h moves the top down by as much as the box shrinks (or up as it grows), so the feet stay put.STAND_H tall, so jump does nothing.STAND_H, write DUCK_H.update, under the ground block, write the comment and the three duck lines.jump, add && runner.h === STAND_H.Skills: Keyboard and mouse input, Collision detection
← Which keys are down? Build it yourself: jump buffering →