左,右箭头和空格键上的jQuery kepress检测 [英] jQuery kepress detection on left, right arrows and space bar

查看:125
本文介绍了左,右箭头和空格键上的jQuery kepress检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在此处使用一些jQuery来检测正在按下的键.

I'm trying to use a little jQuery here to detect which keys are being pressed.

我有很多关于尝试使用函数来检测ASCII码并查看被按下的键的信息,但我有些困惑.

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.

此外,keyUp,keyDown和keypress有什么区别?

Also, what's the difference between keyUp, keyDown and keypress?

推荐答案

keydown:
当用户按下键时触发.在用户按住键的同时重复该操作.

keydown:
Fires when the user depresses a key. It repeats while the user keeps the key depressed.

按键:
当在例如文本输入中插入实际字符时触发.在用户按住键的同时重复此操作. Safari iPhone不支持.

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.

来自: http://www.quirksmode.org/dom/events/keys .html

这篇关于左,右箭头和空格键上的jQuery kepress检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆