Answer the question
In order to leave comments, you need to log in
How to simulate pressing the "down" and "up" buttons when the input is selected?
There is an input on the page, it is in focus, is it possible to somehow perform the default scrolling of the page when the user presses "down" and "up"? Of course, I can simply increase or decrease the scroll when these buttons are pressed, but I wonder if it is possible to somehow simulate the default browser event. Thank you!
Answer the question
In order to leave comments, you need to log in
You can jsfiddle.net/oxjaoLas
var $win = $(window);
$('.inp').on('keydown', function (e) {
switch (e.which) {
case 38:
var top = $win.scrollTop();
top -= 10;
$win.scrollTop(top);
break;
case 40:
var top = $win.scrollTop();
top += 10;
$win.scrollTop(top);
break;
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question