mousemove event javascript code example
Example 1: javascript canvas mousemove
// on brouser
var canv = document.getElementById('my_canvas');
canv.addEventListener('mousemove', e => {
console.log({x:e.offsetX, y:e.offsetY, z:e})
});
// for mobile on touch
var canv = document.getElementById('my_canvas');
canv.addEventListener('touchmove', e => {
ee = e.touches[0];
console.log({x:ee.clientX, y:ee.clientY, z:e})
});
Example 2: javascript mouse events
element.addEventListener("mousemove", function(event) {
console.log(event);
}); //Calls function every time the mouse moves over 'element'