HTML5 game publishing
Coyote Time and Input Buffering for Tight Platformer Controls
A short grace period after leaving a ledge and a remembered jump press fix most it-did-not-jump complaints. Code, starting values, variable jump height and hitbox forgiveness.
The difference between a platformer that feels good and one that feels "off" is often a fraction of a second that the player never notices consciously. Two techniques, coyote time and input buffering, forgive tiny timing errors in the player's favour. Almost every polished platformer, obstacle runner and parkour game uses them. This post explains both, shows the code and gives starting values you can tune.
The problem they solve
A player sees themselves run off a ledge, presses jump a moment later, and nothing happens, because the game already considers them airborne. Or they press jump a few frames before landing, and the game ignores the press because the character was not on the ground yet. In both cases the player did what they meant, and the game punished a timing error well below their reaction time. They blame the game, correctly.
Coyote time: a grace period after leaving the ground
Coyote time, named after the cartoon character who stays in the air for a moment after running off a cliff, lets the player jump for a short time after walking off an edge.
const COYOTE = 0.10; // seconds
let coyoteTimer = 0;
function update(dt) {
if (player.onGround) coyoteTimer = COYOTE;
else coyoteTimer = Math.max(0, coyoteTimer - dt);
// ...
}
function canJump() {
return coyoteTimer > 0;
}
When the player jumps, set coyoteTimer = 0 immediately, or they could jump twice by pressing in quick succession. Values around 0.08 to 0.12 seconds (five to seven frames at 60 Hz) work for most games. Too long and players can jump off thin air visibly, which looks like a double jump.
Input buffering: remember the press
Input buffering stores a jump press for a short window, so that if the character lands within that window, the jump fires on landing.
const BUFFER = 0.12;
let jumpBuffer = 0;
window.addEventListener('keydown', e => {
if (e.code === 'Space' && !e.repeat) jumpBuffer = BUFFER;
});
function update(dt) {
jumpBuffer = Math.max(0, jumpBuffer - dt);
if (jumpBuffer > 0 && canJump()) {
doJump();
jumpBuffer = 0;
coyoteTimer = 0;
}
}
Notice the two work together: the buffered press is consumed the first moment canJump() is true, which covers both a landing and a coyote window. Keep the buffer short, about 0.1 to 0.15 seconds. A long buffer makes the character jump when the player has already forgotten they pressed.
Variable jump height
A related feel improvement is letting the player control height by how long they hold the button. On release, cut the upward velocity:
window.addEventListener('keyup', e => {
if (e.code === 'Space' && player.vy < 0) player.vy *= 0.45;
});
This gives precision with one button. Combine it with slightly stronger gravity on the way down than on the way up, which makes jumps feel snappy rather than floaty.
More forgiveness that players never see
- Corner correction. If the player's head clips a corner by a pixel or two, nudge them sideways instead of stopping them. It removes the "I clearly cleared that" frustration.
- Ledge grab leniency. A slightly larger detection zone for grabbing edges.
- Smaller hitboxes. A player hitbox about 10 to 20 percent smaller than the sprite makes dangers feel fair. Make pickups' hitboxes bigger than their sprites for the same reason.
- Attack buffering. The same trick applies to any action: dash, shoot or swing.
The principle is to be strict with the enemy and generous with the player. Players call this "tight controls".
Frame rate independence
All the values above are in seconds, not frames, so they behave the same at 60 Hz and 144 Hz. Make sure your update uses dt in seconds and, ideally, a fixed timestep, as described in fixed timestep game loops in JavaScript. Otherwise, a 5-frame coyote window is twice as long on a 120 Hz display.
Touch controls need it more
On a phone, taps are less precise and the player's thumb covers part of the screen. Use a longer buffer on touch, about 0.15 to 0.2 seconds, and make touch targets large. The input layer in keyboard, touch and gamepad input for HTML5 games shows how to treat all devices through one set of actions, so these timers live in one place.
Tuning and testing
- Expose
COYOTEandBUFFERas variables in a debug panel so you can change them at runtime. - Playtest with someone who has not seen the game and watch for "it did not jump" comments. Those are your missing forgiveness.
- Turn the values to zero for a moment to feel the difference. It is striking.
- Record any deaths players report as "unfair" and check them against your hitboxes.
Our guide on game feel and juice covers the visual side of the same idea. For a player's view of what makes platform challenges fair or cruel, see obby parkour tips.


