火狐浏览器在按下
请参考此 CodePen。
它不仅在
但我在想,如果这是Firefox中的一个bug,那么为什么Firefox和其他浏览器之间存在不一致性呢?
tab, shift, up/down/left/right arrow
键时会触发 keypress
回调函数,但是 Chrome,Safari 和 IE 则不会触发。请参考此 CodePen。
它不仅在
keypress
上触发回调函数,而且在按下 tab, shift, up/down/left/right arrow
键时将 keyCode
传递为 0
。
我可以
var charCode = (typeof e.which === 'number') ? e.which : e.keyCode;
if (charCode === 0) return;
但我在想,如果这是Firefox中的一个bug,那么为什么Firefox和其他浏览器之间存在不一致性呢?
Firefox
的一个bug。 - Sarbbottam