jQuery .keypress amp; .keydown .which(jQuery .keypress amp;.keydown .which)
问题描述
好的,.keypress 和 .keydown/.keyup 有什么区别?目前我正在使用 .keydown ,它为我的键返回 38 的 .which 值,现在如果我将其更改为 .keypress 它为同一个键返回 109 的值.有什么区别?为什么同一个键的值不同?
Ok so what is the difference in .keypress and .keydown/.keyup? At present I am using .keydown which returns a .which value of 38 for my key, now if i change it to .keypress it returns a value of 109 for that same key. What is the difference and why are the values different for the same key?
推荐答案
如果你按下一个按钮,它会触发一个 keydown
并释放它会触发一个 keyup
.keypress
通常介于这两者之间.
If you press a button it fires a keydown
and releasing it fires a keyup
. The keypress
usually comes between those two.
keydown
和 keyup
讨论哪个 key 已更改.keypress
告诉该键代表哪个字符.
keydown
and keyup
talk about which key has been changed. keypress
tells which character that key represents.
请注意,这完全取决于浏览器!
Note that this is all browser-dependent!
请参阅这篇文章,了解在不同浏览器上实现的关键事件之间的差异.
这篇关于jQuery .keypress &.keydown .which的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:jQuery .keypress &.keydown .which


基础教程推荐
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- 直接将值设置为滑块 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01