I needed something like that, but for mousewheel a while ago and I made this code:
function createFakeMouseEvent(event, elemento) {
var evt;
if (!(window.mozInnerScreenX == null)) {
// Firefox
evt = document.createEvent("MouseEvents");
evt.initMouseEvent(event, true, true, window, 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, null);
elemento.dispatchEvent(evt);
} else {
if ('onwheel' in document) {
// Chrome, PhantomJS, Safari
evt = document.createEvent("MouseEvents");
evt.initMouseEvent(event, 0, 100, window, 0, 0, 0, 0, null, null, null, null);
elemento.dispatchEvent(evt);
} else if ( !! document.createEvent) {
// IE9
evt = document.createEvent("HTMLEvents");
evt.initEvent(event, true, false);
elemento.dispatchEvent(evt);
} else if (document.documentMode == 9) {
// IE10+, Safari
var evt = document.createEvent("MouseEvents");
evt.initEvent(event, true, true);
elemento.dispatchEvent(evt);
} else {
// IE8
var evt = document.createEventObject();
elemento.fireEvent(event, evt);
}
}
}
The code got a bit complex because different browsers have different ways of firing events ... But it should work for what they want.