mardi 26 septembre 2017

how to stop keydown function after click a button

i have js code when i press key 38, 40 13 those function works respectively. but what i want to do is ,when i click this button keydown function block will be disable, and when i hover this button this keydown function block will be enable.

$(document).keydown(function(e){
if (e.keyCode == 38) { 
   verticalSlideDown();
   //console.log("pressed key for Down : "+e.keyCode);
}
if (e.keyCode == 40) { 
   verticalSlideUp();
   //console.log("pressed key for Up: "+e.keyCode);
}
if (e.keyCode === 13) {
    var div= $(".scroll-inner-container");
    //console.log("pressed key for stop : "+e.keyCode);
   div.stop();
}
});

this is my html button:

<button class="keyboard-btn">click here</button>




Aucun commentaire:

Enregistrer un commentaire