keypress event not working in IE and Chrome but working in FF

前端 未结 3 1093
甜味超标
甜味超标 2020-12-10 02:58

Any idea why this might happen? I would usually think that Chrome would be more forgiving with the codes?

$(document).keypress(function(e) {
    if(e.keyCode         


        
3条回答
  •  时光取名叫无心
    2020-12-10 03:39

    yes this can be achieved by changing onkeypress event to onkeydown. Moreover this issue exists just in case of Internet Explorer when you want to trigger an event on space click.

提交回复
热议问题