Skip to content

Instantly share code, notes, and snippets.

@AllThingsSmitty
Created July 28, 2016 23:18
Show Gist options
  • Save AllThingsSmitty/13a88cdf7029eb901ea9a2c301708142 to your computer and use it in GitHub Desktop.
Save AllThingsSmitty/13a88cdf7029eb901ea9a2c301708142 to your computer and use it in GitHub Desktop.
Disable right-click menu
// credit: Louis Lazaris
window.addEventListener('contextmenu', function (e) {
console.log('context menu disabled');
e.preventDefault();
}, false);
document.addEventListener('mouseup', function (e) {
if (e.button === 2) {
console.log('right-click enabled');
}
}, false);
// https://jsbin.com/diyihu/edit?html,css,js,console,output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment