jQuery kepress 检测左、右箭头和空格键

发布于 2024-09-15 16:48:19 字数 128 浏览 10 评论 0原文

我试图在这里使用一些 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技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伤痕我心 2024-09-22 16:48:19

按键:
当用户按下某个键时触发。当用户按住该键时,它会重复。

按键:
例如,当将实际字符插入文本输入时触发。当用户按住该键时,它会重复。 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

画离情绘悲伤 2024-09-22 16:48:19
  1. 当按下某个键时会触发按键按下事件。
  2. 如果用户继续按住按键以重复某个字符,则会为实际键入的每个字符触发按键事件。
  3. 释放按键时会触发按键弹起事件。
  1. A key down event is fired when a key is pressed down.
  2. A key press event is fired for every character that is actually typed if a user continues to hold down the key to let a character repeat.
  3. A key up event is fired when the key is released.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文