Retrieve the mouse position on the image

Hi! Using the the example plugin as a starting point, I’m trying to retrieve the mouse position over the image:

index.js

function onMouseMove(e)
{
  console.error(`Mouse ${e.pageX}, ${e.pageY}`);
}

document.addEventListener('mousemove', onMouseMove, false);

The problem is that it only prints the coordinates when the mouse is over the plugin’s panel.
Is there any way to get the mouse position when the cursor is over the canvas?

I believe it’s the same question

Please continue there