xyflow/xyflow

useKeyPress doesn't track repeated combination keypresses until the entire combination is released

開放

#2,248 建立於 2022年6月28日

 (14 則留言) (6 個反應) (0 位負責人)TypeScript (1,282 個分叉)batch import
help wantedtopic:keys

倉庫指標

星標
 (19,286 顆星)
PR 合併指標
 (平均合併 2天 1小時) (30 天內合併 20 個 PR)

描述

Describe the Bug

When using useKeyPress to track combinations of keys, for example Meta+z, repeated keypresses are not captured if you continue to hold down the Meta key.

Your Example Website or App

https://codesandbox.io/s/recursing-driscoll-stvwou?file=/src/App.js

Steps to Reproduce the Bug or Issue

When const comboPressed = useKeyPress("Meta+z");:

  • Press and hold Meta
  • Press and hold z
  • comboPressed is true
  • Release z
  • comboPressed is still true and so additional presses of z can't be detected
  • Release Meta
  • comboPressed is now false

The inverse does not have the same behaviour:

  • Press and hold z
  • Press and hold Meta
  • comboPressed is true
  • Release Meta
  • comboPressed is now false and so additional presses of z can be detected

Expected behavior

As a user I would expect that after I press Meta and z, and then continue to hold Meta but release z that the pressed state of useKeyPress("Meta+z") is false.

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: 103.0.5060.53

Additional context

No response

貢獻者指南