本文介绍了JavaScript监听器,“keypress”没有检测到退格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在使用按键听众,例如.. I'm using a keypress listener eg.. addEventListener("keypress", function(event){}但是,这似乎没有检测到删除文本的退格... However, this doesn't seem to detect a backspace which erases text... 我可以使用不同的侦听器来检测这个吗?Is there a different listener I can use to detect this?推荐答案仅对字符(可打印)键调用KeyPress事件,为所有包括非打印的键提供KeyDown事件,例如, Shift ,,等。KeyPress event is invoked only for character (printable) keys, KeyDown event is raised for all including nonprintable such as , , , , etc.更新: 当按下一个键并且该键通常产生一个字符值时会触发按键事件 The keypress event is fired when a key is pressed down and that key normally produces a character value 参考。 这篇关于JavaScript监听器,“keypress”没有检测到退格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-16 11:41