ajax - javascript keyboard functions -
how can make function when press down example "a" key on keyboard pushes down on , sends out signal nupp('/ts'). on "a" key relase should top sending signal nupp('/ts').
<html> <head> <script src=\"https://code.jquery.com/jquery-2.2.4.min.js\"></script> <script> client.println("function nupp(url){ $.ajax(url); }"</script> <button type=\"button\" onclick=\"nupp('/ts');\">on</button> </head> <body>
you can this:
function checkkeydown(key) { if (key.keycode == "38") { $.ajax("/f"); } else if (key.keycode == "37") { $.ajax("/l"); } else if (key.keycode == "39") { $.ajax("/r"); } else if (key.keycode == "40") { $.ajax("/b"); } } function checkkeyup(key) { if (key.keycode == "38" || key.keycode == "37" || key.keycode == "39" || key.keycode == "40") { $.ajax("/s"); //stop } }
Comments
Post a Comment