Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`useKeyHold` / `KeyStateTracker` latches a modifier forever when a `keyup` is swallowed without a `blur` (e.g. macOS Cmd+Shift+4)

Aperta
#143 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
50/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
typescript
Ambito
frontend

Direzione di ricerca

Inizia dal punto di ingresso useKeyHold e dal comportamento globale di KeyStateTracker, riproducendo il problema nel CodeSandbox collegato con Cmd+Shift+4 su macOS. Analizza come il tracker gestisce gli eventi keyup ignorati senza un window blur; il lavoro è completo quando useKeyHold('Shift') restituisce false dopo che la scorciatoia è stata annullata o completata senza richiedere un'altra pressione fisica di un tasto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

TanStack Hotkeys version

10.0.0

Framework/Library version

React v19.2.0

Describe the bug and the steps to reproduce it

useKeyHold('Shift') (and every consumer of the global KeyStateTracker) can get permanently stuck reporting a modifier as held. The tracker only learns a key was released from a discrete keyup event, and its only recovery path for a missed keyup is a window blur. Any OS-level interaction that swallows the keyup without blurring the browser window strands the held state indefinitely — every subsequent useKeyHold read returns true until the user physically taps and releases that key again.

Reproduction

  1. Render anything using const shift = useKeyHold('Shift').
  2. On macOS, focus the page and press Cmd+Shift+4 (screenshot-to-selection).
  3. Press Esc to cancel (or take the shot).
  4. Observe useKeyHold('Shift') is now stuck at true, even though nothing is held.

Other triggers in the same class: Spotlight (Cmd+Space), Mission Control, and various OS shortcuts that consume a modifier keyup while leaving the browser window focused.

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://codesandbox.io/p/sandbox/stoic-fast-h5k2pr

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

No, because I do not have time to dig into it

Terms & Code of Conduct
  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Lingua principale
TypeScript
Stelle
729
Fork
47
Merge medio
18h 46m
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TanStack/hotkeys

Tutte le issue di TanStack/hotkeys

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.