TanStack Hotkeys version#
v0.9.1
Framework/Library version#
React v18.3.1
Describe the bug and the steps to reproduce it#
there are cases when when you don't want to introduce a useCallback dependency
const isCtrlKeyDown = useKeyHold('Control');
const onWheel = useCallback((event: MouseEvent) => {
}, []);
current implementation assumes you always rely on state
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)#
https://stackblitz.com
Screenshots or Videos (Optional)#
No response
Do you intend to try to help solve this bug with your own PR?#
Yes, I think I know how to fix it and will discuss it in the comments of this issue
Terms & Code of Conduct#
getKeyStateTracker().isKeyHeld('Control')reads the current state without subscribing, so it works in a stable callback with no extra dependencies (see Reading held keys inside a stable callback).