Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useKeyPress中,keyFilter为['meta.uparrow.1'], 触发相应事件,没有调用回调 #2284

Closed
DanielLeefu opened this issue Aug 7, 2023 · 1 comment
Assignees
Labels
documentation Improvements or additions to documentation wontfix This will not be worked on

Comments

@DanielLeefu
Copy link

DanielLeefu commented Aug 7, 2023

mac电脑,meta对应command按键,代码如下,按下command,不会触发console

useKeyPress(
    ['meta.uparrow.1'],
    () => {
      console.log('done');
    },
 );

期望: 按下 ⌘ +↑+ 1 组合键后可以触发console.log

@liuyib
Copy link
Collaborator

liuyib commented Aug 7, 2023

这是浏览器的限制,目前原因不明。我测了下 Mac 系统中,Chrome、FireFox、Edge 浏览器都无法触发“Command + 数字键”。

你这里的快捷键 meta.uparrow.1 就命中了系统的这个限制。

可以自己用 JS 尝试下,可以验证原生就不支持:

window.addEventListener('keydown', (e) => {
  console.log('e.key', e.key);
})

后面我会在文档里加上 FAQ 说明系统的这个限制。


相关 issue、PR:

以前发现 Mac 系统下对 keyup 事件的限制比较多,现在来看对 keydown 也会有限制

@liuyib liuyib added documentation Improvements or additions to documentation wontfix This will not be worked on labels Aug 7, 2023
@liuyib liuyib self-assigned this Aug 7, 2023
@liuyib liuyib closed this as completed Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants