Problem description:
The onChange callback passed to the KeyboardControls component becomes stale and continues to refer to the initial function closure.
This occurs because the internal event listener registration within KeyboardControls is missing the onChange prop from its useEffect dependency array.
See https://github.com/pmndrs/drei/blob/master/src/web/KeyboardControls.tsx#L111
Environment:
three version: 0.180.0
@react-three/fiber version: 10.7.6
@react-three/drei version: 9.3.0
node version: v22.18.0
npm version: 10.9.3
Relevant code:
See https://codesandbox.io/p/sandbox/quizzical-water-6yy5tn
Suggested solution:
Add onChange to the above usEffect deps array.