Run Jquery method when enter key is pressed

后端 未结 4 682
自闭症患者
自闭症患者 2021-01-14 02:09

I\'m trying to run a method when the enter key has been pressed. This method is already being used by a button. Basically, when the user fills in a text field and clicks a s

4条回答
  •  庸人自扰
    2021-01-14 02:46

    $(document).keydown(function(e) {
       // test for the enter key
       if (e.keyCode == 13) {
          // Do your function
          myFunction();
       }
    });
    

提交回复
热议问题