jQuery Keypress Arrow Keys

前端 未结 6 1131
自闭症患者
自闭症患者 2020-11-28 05:30

I\'m attempting to capture arrow key presses in jQuery, but no events are being triggered.

$(function(){
    $(\'html\').keypress(function(e){
        consol         


        
6条回答
  •  萌比男神i
    2020-11-28 05:52

    Please refer the link from JQuery

    http://api.jquery.com/keypress/

    It says

    The keypress event is sent to an element when the browser registers keyboard input. This is similar to the keydown event, except that modifier and non-printing keys such as Shift, Esc, and delete trigger keydown events but not keypress events. Other differences between the two events may arise depending on platform and browser.

    That means you can not use keypress in case of arrows.

提交回复
热议问题