我正在使用 keypress
监听器,例如..
addEventListener("keypress", function(event){
}
但是,这似乎没有检测到删除文本的退格键......
我可以使用不同的监听器来检测吗?
最佳答案
KeyPress 事件仅针对字符(可打印)键调用,KeyDown 事件针对所有包括不可打印键(例如 Control、Shift、Alt、退格键等
更新:
The keypress event is fired when a key is pressed down and that key normally produces a character value
关于JavaScript 监听器, "keypress"不检测退格键?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4843472/