Answer the question
In order to leave comments, you need to log in
How not to scroll div when pressing UP and DOWN keys?
Hello! There is a dropdown div and it has overflow-x: auto; and you need to navigate through the elements using the up, down, left and right keys, but at the same time so that the div does not scroll, how to do this? I plan to use angular-hotkeys to control keystrokes .
Solution:
I wrote ng-keydown="arrows($event)" in the div, in the function
switch (event.keyCode) {
case 40:
// здесь выполняю действия по нажатию
event.preventDefault();
break;
.....
}
Answer the question
In order to leave comments, you need to log in
Vash_div.addEventListener("keydown", function(e){
e = e||event;
e.preventDefault ? e.preventDefault() : (e.returnValue=false);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question