right click event listener javascript code example
Example 1: javascript detect right click
el.addEventListener('contextmenu', function(ev) {
ev.preventDefault();
alert('success!');
return false;
}, false);
Example 2: how to add a right click listener javascript
element.addEventListener('contextmenu', (e) => {
e.preventDefault();
alert('Success');
}, false);
Example 3: click left event listener javascrip
object.addEventListener("contextmenu", myScript);