I want to simulate a scroll down with the "Page Down" button in a page. I have the call to a function every 2 seconds, but dont know how to connect it with the keyboard buttons (how to simulate a keyboard button press?).
var interval = null;
jQuery(function(){
interval = setInterval(callFunc, 2000);
});
function callFunc(){
jQuery('.link1, .link2, .link3').trigger('click');
}
This seems to work, meaning that when inserted in the console it call the callFunc function every 500ms, but I cant fix the part inside the function to simulate the button press. (keycode for "page down" button is 34)
var interval = null;
$(function(){
interval = setInterval(callFunc, 500);
});
function callFunc(){
var event = $.Event('keypress');
event.which = 34;
event.keyCode = 34;
$(this).trigger(event);
}
Anyone?