I try to prevent contextual menu to be displayed on right click with Paperjs. I tried to catch the right click event with the following JS code:
window.addEventListener("contextmenu", function(event){
//document.body.addEventListener("contextmenu", function(event){
console.log ('Right click');
//event.stopImmediatePropagation();
event.stopPropagation();
return false;
//return true;
});
I tried many combinations (commented lines). None is working. I can't figure out why it is not working, while the following line does the job:
<body oncontextmenu="return false;">
I can't add attribute to <body> so I would like to do in from the JavaScript.
Here is a JSFiddle: https://jsfiddle.net/Imabot/zujxaL95/5/