jQuery Event Keypress: Which key was pressed?

后端 未结 24 2137
半阙折子戏
半阙折子戏 2020-11-21 16:48

With jQuery, how do I find out which key was pressed when I bind to the keypress event?

$(\'#searchbox input\').bind(\'keypress\', function(e) {});
         


        
24条回答
  •  遥遥无期
    2020-11-21 16:52

    Add hidden submit, not type hidden, just plain submit with style="display:none". Here is an example (removed unnecessary attributes from code).

    it will accept enter key natively, no need for JavaScript, works in every browser.

提交回复
热议问题