jQuery kepress 检测左、右箭头和空格键
我试图在这里使用一些 jQuery 来检测按下了哪些键。
我经常尝试使用函数来检测 ASCII 代码等来查看按下了哪些键,但我有点困惑。
另外,keyUp、keyDown 和 keypress 之间有什么区别?
I'm trying to use a little jQuery here to detect which keys are being pressed.
I've a lot about trying to use functions to detect ASCII codes and such to see which keys are being pressed, but I'm a little confused.
Also, what's the difference between keyUp, keyDown and keypress?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
按键:
当用户按下某个键时触发。当用户按住该键时,它会重复。
按键:
例如,当将实际字符插入文本输入时触发。当用户按住该键时,它会重复。 iPhone Safari 不支持。
按键:
当用户在执行该键的默认操作后释放该键时触发。
来自:http://www.quirksmode.org/dom/events/keys.html< /a>
keydown:
Fires when the user depresses a key. It repeats while the user keeps the key depressed.
keypress:
Fires when an actual character is being inserted in, for instance, a text input. It repeats while the user keeps the key depressed. Not supported by Safari iPhone.
keyup:
Fires when the user releases a key, after the default action of that key has been performed.
From: http://www.quirksmode.org/dom/events/keys.html