Home > front end >  About the onkeydown event - when key press will continue to trigger events
About the onkeydown event - when key press will continue to trigger events

Time:09-23

 
The function the stop () {
$.post ('/sex/stop ', function () {});
}

Document. The onkeydown=function (event) {
If (event. KeyCode==87) {the stop (); }
}

When button hold don't put double running continuously and stop () function
Excuse me big door!
How can set runs only once the stop () function
Submit only one $. Post

When there are two or more to determine key is hold still to how to deal with?


CodePudding user response:

Can set up a public variable flag=true, keyCode==87, then the if (flag) stop} {implementation, execute the stop will begin with a flag=false, the execution of the callback function, such as to flag=true

CodePudding user response:

Thank you very much!!!!!!!!!!! I set the flag=true found if the flag is added to stop () in=false only by one time two times, no effect
Then I think a method using a onkeyup events to invoke the flag=true then press the button again also can
  • Related