detect mouse click javascript code example
Example 1: detect mouse javascript
import Tappify from "tappify";
function myComponent() {
return <>
<Tappify.Finger>
Client is using finger *tap tap*
</Tappify.Finger>
<Tappify.Cursor>
Client is using mouse cursor *click click*
</Tappify.Cursor>
</>
}
Example 2: javascript detect right click
el.addEventListener('contextmenu', function(ev) {
ev.preventDefault();
alert('success!');
return false;
}, false);
Example 3: javascript detect right click
document.body.onclick = function (e) {
var isRightMB;
e = e || window.event;
if ("which" in e)
isRightMB = e.which == 3;
else if ("button" in e)
isRightMB = e.button == 2;
alert("Right mouse button " + (isRightMB ? "" : " was not") + "clicked!");
}