How to disable copy paste and mouse right click on Joomla sites?




Sometimes we need to prevent visitors from copying and pasting text from Joomla pages. To protect your content from being copied we need to disable keyboard shortcuts, such as Ctrl + C and Ctrl + V, and mouse right click. 


In this short tutorial, we’ll show you how to protect your content in a few simple steps with jQuery.



1. Copy the JS code below and paste it into a custom JavaScript file:

jQuery(window).on('keydown', function(e){ if ((e.keyCode == 123 && e.originalEvent && e.originalEvent.code == 'F12') || (e.keyCode == 73 && (e.ctrlKey || e.metaKey) && e.shiftKey) || (e.keyCode == 67 && (e.ctrlKey || e.metaKey) && e.shiftKey) || (e.keyCode == 75 && (e.ctrlKey || e.metaKey) && e.shiftKey) || (e.keyCode == 83 && (e.ctrlKey || e.metaKey) && e.shiftKey) || (e.keyCode == 81 && (e.ctrlKey || e.metaKey) && e.shiftKey) || (e.keyCode == 116 && e.shiftKey && e.originalEvent.code == 'F5') || (e.keyCode == 118 && e.shiftKey && e.originalEvent.code == 'F7') || ((e.ctrlKey || e.metaKey) && (e.keyCode == 88 || e.keyCode == 65 || e.keyCode == 67 || e.keyCode == 86 || e.keyCode == 83))) { e.preventDefault(); e.stopPropagation(); } }); jQuery(document).off('contextmenu').on('contextmenu', function(e){ e.preventDefault(); e.stopPropagation(); });

Related articles