xyflow/xyflow

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

Open

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

在 GitHub 查看
 (14 留言) (6 反應) (0 負責人)TypeScript (19,286 star) (1,282 fork)batch import
help wantedtopic:keys

描述

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

貢獻者指南