<canvas id="canvas" onmousemove="onMouseMove(event)"></canvas>
<script>
let canvas = document.getElementById("canvas");
function onMouseMove(evt) {
let mousePos = getMousePos(evt);
console.log("Mouse X : " + mousePos.x + ", Mouse Y : " + mousePos.y);
}
function getMousePos(evt) {
let rect = canvas.getBoundingClientRect();
return {
x: evt.clientX - rect.left,
y: evt.clientY - rect.top
};
}
</script>
Code Example |
---|
Html :: bootstrap flex align |
Html :: upload icon font awesome |
Html :: twitter icon html5 |
Html :: icons burger css font awesome |
Html :: write & in html |
Html :: font awesome |
Html :: open new tab html |
Html :: html file |
Html :: fafa login icons html code |
Html :: html pi symbol |
Html :: change tab icon html |
Html :: how to open in new page link html |
Html :: dropdown in html |
Html :: twitter card meta tags |
Html :: html meta charset content ie edge |
Html :: rel noopener noreferrer nofollow |
Html :: html select default blank |
Html :: fa-fa-home |
Html :: how to add a table in html |
Html :: bootstrap 5 datalist example |
Html :: bootstrap href button |
Html :: laravel murakkab old request |
Html :: disable a tag |
Html :: copyright sign in html |
Html :: css setting table column width |
Html :: html numeric keyboard |
Html :: how to set domain name on localhost linux ubuntu xampp |
Html :: jinja mark text as safe |
Html :: meta initial scale |
Html :: how to create table row in javascript |