从键盘或数字键盘识别 2 键
我想向我的网络应用程序添加键盘快捷键。
但对于其中之一,我需要能够区分使用小键盘输入的数字和在 qwerty 字符上方输入的数字(我的用例是法语键盘,所以它是 azerty,但我认为这不是问题)。我会将其与大写锁定激活的检测结合起来。
这可能吗?
I would like to add keyboard short-cuts to my web application.
But for one of them, I need to be able to distinguish between the digits entered with the numpad from the one entered above the qwerty chars (my use case is for French keyboards, so it's azerty, but I don't think it's a problem). I'll combine it with a detection of the caps lock activation.
Is that possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
浏览器中的键码检测非常混乱:检查 quirksmode.org 兼容性表。
根据这个列表,不过,令我惊讶的是,实际上似乎可以区分两者:
还没有尝试过,但绝对值得一试。
Keycode detection is pretty chaotic in browsers: Check the quirksmode.org compatibility table.
According to this list, though, surprisingly to me, it seems in fact to be possible to distinguish the two:
Haven't tried this but it's definitely worth a try.
阅读
keyCode
和onkeyup
事件。Read up on
keyCode
and theonkeyup
event.