How To Disable Copy Paste And Mouse Right Click

How To Disable Copy Paste And Mouse Right Click

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 Gridbox and jQuery.


1. Copy JS code below:

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();
    });


2. Paste code to the Gridbox JavaScript editor.

Javascript CSS Editor

You don't need to install any extra Joomla plugins, use this tip to disable copy paste, enjoy! Need more assistance? Feel free to write any questions in the comments form below.