Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get mouse x and y in javascript

document.addEventListener("mousemove", () => {
  let mousex = event.clientX; // Gets Mouse X
  let mousey = event.clientY; // Gets Mouse Y
  console.log([mousex, mousey]); // Prints data
});
 
PREVIOUS NEXT
Tagged: #mouse #javascript
ADD COMMENT
Topic
Name
9+7 =