-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
fix(useKeyPress): make alias of keyCode more compatible #2054
Conversation
@miracles1919 @crazylxr review, please ❤️ |
keyCode 兼容 Firefox 的文档有吗 @liuyib |
有:https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode#value_of_keycode,各个操作系统,各个浏览器下的数据都有。 之前实现这个 PR 时,我是参考的一个非官方的文档:https://unixpapa.com/js/key.html, 另外,keyCode 已经废弃了,而且各个平台差异繁多,还有必要在 keyCode 方案上做努力吗?其他的 hooks 库目前采用
ahooks 有没有考虑切换至“ |
keyCode 兼容确实麻烦,但是替换的话改动比较大了。v3 不考虑了,可以 v4 再切换 |
2741096
to
b895580
Compare
参考 MDN 上 keyCode 的兼容性表,全部核对了一遍,补充了下面这些键的兼容值: 可以 review 下 @miracles1919 |
以
... 兼容起来太麻烦了,维护成本也高,我建议是在下个版本用 |
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
close: #1467
💡 Background and solution
background:
event.keyCode
are different between Chrome and Firefox.useKeyPress
is not compatible with Firefox.solution:
set the value of
aliasKeyCodeMap
to array, e.g.📝 Changelog
keyCode
is not compatiblekeyCode
未兼容到的值☑️ Self Check before Merge