Js binding keyboard and mouse event sample code

  • 2020-03-30 01:43:23
  • OfStack

1. Bind keyboard enter event (note: if you want to press enter key when submitting with jq, you can submit, so you should not use form.)
 
document.onkeydown = function(evt){ 
var evt = window.event?window.event:evt; 
if(evt.keyCode==13){ 
subcomment(); //If the return key is pressed, the corresponding js function is executed
} 
} 

Related articles: