Replace deprecated 'createEvent' and 'initMouseEvent' by 'new MouseEvent'

'createEvent' is deprecated (see
https://developer.mozilla.org/en-US/docs/Web/API/document.createEvent),
so I implemented the same behavior by using 'new MouseEvent' (see
https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Events/Creating_and_triggering_events#Triggering_built-in_events)