Quick answer: Double inputs happen when the game registers a single input multiple times, usually because it's processed in more than one place, or both via events and polling, so one press counts as two. Stuck keys (or stuck inputs) happen when the game misses the release event, so it thinks a key is still held, often after focus loss (alt-tabbing while holding a key). Fix double input by processing each input exactly once, and stuck keys by reliably handling key-up and resetting input state on focus loss.

Double inputs (one press doing two actions) and stuck keys (an input that won't 'let go') are two common, annoying input bugs with distinct causes. Double input is about processing the same event too many times; stuck keys are about missing the 'released' event. Both undermine the precise control players expect, and both have clear fixes.

Why Double Inputs Happen

A double input occurs when a single physical input is registered as two (or more) actions. The usual cause is processing the same input in multiple places, the input event is handled by more than one piece of code, or the input is processed both via an event callback and via polling each frame, so one press triggers the action twice. It can also come from not distinguishing a press from a hold (re-triggering each frame the key is down when you meant to trigger once on press), or from input events being delivered more than once.

The signature is one input doing the action twice (or repeatedly): a single jump press jumps twice, a menu selection activates two items, a single click registers as two. The cause is almost always the input being handled more times than the player pressed it.

Why Keys Get Stuck

A stuck key happens when the game thinks an input is still held after the player released it, because it missed the release (key-up) event. The classic cause is focus loss: the player holds a key (say, a movement key) and alt-tabs or the window loses focus; the key-up event happens while the game isn't focused, so the game never sees the release and thinks the key is still down, the character keeps moving even after the player let go and returned. Stuck keys also come from any situation where key-up is missed or not handled, leaving the input state stuck 'on.'

The signature is an input that stays active after release, continuous movement, a held action that won't stop, until the player presses and releases the key again (giving the game a key-up it does see). Focus loss is the most common trigger.

How to Fix Both

For double input, process each input exactly once, ensure a given input is handled in a single place, and don't process it both by event and by polling. Distinguish press, hold, and release clearly: trigger once-per-press actions on the press event (not every frame the key is held). Audit for any duplicate handling of the same input. For stuck keys, reliably handle key-up so releases always update the input state, and crucially, reset input state on focus loss, when the window loses focus, clear held-input state (treat all keys as released) so a key-up missed during unfocus doesn't leave an input stuck. Re-syncing input state on focus regain also helps.

These are usually reproducible locally (double input by pressing once and seeing two actions; stuck keys by holding a key and alt-tabbing), so test those scenarios. After fixing, verify single presses do single actions, and that holding a key and losing/regaining focus doesn't leave it stuck. Clean input handling, each input processed once, every release accounted for, focus loss clearing held state, gives players the precise control they expect.

Double input is processing one press twice, process each input once. Stuck keys are a missed release, handle key-up reliably and clear held inputs on focus loss.