且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么不使用jquery keypress事件检测退格?

更新时间:2023-11-05 19:34:46

keypress事件是(在其原始IE中)表单,以及在Safari / Chrome中)关于添加到文本字段的实际字符。退格键显然不会在字段值中添加新字符,因此它不会导致按键事件。

The "keypress" event is (in its original IE form, and in Safari/Chrome) about an actual character being added to a text field. The backspace key clearly does not add a new character to the field value, so it causes no keypress event.

Firefox和Opera对于生成输入更加不知所措事件。

Firefox and Opera are a little more willy-nilly about generating typing events.

PPK( quirksmode 认为IE和Webkit行为是明智的行为,我非常同意。

PPK (quirksmode) considers the IE and Webkit behaviors to be the sensible ones, and I pretty much agree.