Fix incorrect order of downKeys
YuxuanWeng opened this issue · comments
I discovered that when using hotkeys('*', {keyup:true, keydown:true}, handler)
, with the keyup
and keydown
options set to true, if there are other hotkeys('*', {}, handler2)
listeners present, the _downKeys
order gets rearranged. This causes an issue when I'm implementing keyboard shortcuts persistence because the order of keycodes
retrieved using getPressedKeyCodes
after keyup is incorrect.
Here is the reproducible link: https://codesandbox.io/s/eager-pond-cstwrz?file=/src/App.tsx
@YuxuanWeng Your fix has been reverted because it caused some problems with scope
. #434
https://codesandbox.io/s/eager-pond-cstwrz?file=/src/App.tsx
@jaywcjlove 大佬可以看下这个case吗?先按住cmd再按住k,getPressedKeyString的结果会出现k+cmd,而不是cmd+k
先摁的 k
键,再摁 cmd
会出现这种问题,我想了一下,如果先摁 c
再摁 cmd
也不能复制
重现问题
按住 cmd
,第一次按 k
返回 cmd+k
, 不松开 cmd
第二次按 k
返回 k+cmd