How to detect pressing Enter on keyboard using jQuery?

后端 未结 18 2506
有刺的猬
有刺的猬 2020-11-22 11:07

I would like to detect whether the user has pressed Enter using jQuery.

How is this possible? Does it require a plugin?

EDIT: It looks like I need

18条回答
  •  天涯浪人
    2020-11-22 11:33

    You can do this using the jquery 'keydown' event handle

       $( "#start" ).on( "keydown", function(event) {
          if(event.which == 13) 
             alert("Entered!");
        });
    

提交回复
热议问题