window.addEventListener('contextmenu', function (e) { // do something here... e.preventDefault(); }, false); Code language: JavaScript (javascript)