How to disable Copy, Paste, Cut and Right Click using jQuery ? Last Updated : 28 Nov, 2019 Comments Improve Suggest changes Like Article Like Report The ctrl+c, ctrl+v, ctrl+x and a right-click of the mouse is used to copy, paste and cut anything from anywhere. It can be disable for particular task or page. Let see how to disable cut, copy, paste and right-click. It can be done in two ways: By using an on() method By using keydown() and mousedown() method By using an on() method: It is a built-in method in jQuery. With the help of this method, we will able to disabled the cut, copy, paste and right-click option. Syntax: $(“selector”).on(event, function) Example: javascript <!DOCTYPE html> <html> <head> <title>The jQuery Example</title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script> <style> #geek { padding: 65 px 0; } </style> <script> $(document).ready(function() { // Disables ctrl+v, ctrl+x, ctrl+c. $('textarea').on("cut", function(e) { $("#d2").text('cut. not allowed!'); e.preventDefault(); }); $('textarea').on("copy", function(e) { $("#d2").text('copy. not allowed!'); e.preventDefault(); }); $('textarea').on("paste", function(e) { $("#d2").text('paste. not allowed!'); e.preventDefault(); }); // Above all three can be combined into one, above is // executed separately for understanding purposes. /* $('textarea').on("cut copy paste", function(e) { $("#d2").text('right-click is disabled!'); e.preventDefault(); }); */ // Disables right-click. $('textarea').mousedown(function(e) { if (e.button == 2) { e.preventDefault(); alert('right-click is disabled!'); } }); }); </script> </head> <body> <center> <div id='geek'> <h1 style="color:green">GeeksforGeeks</h1> <p id="d1"> The below textarea won't allow any cut, copy, paste and right-click operations. </p> <textarea></textarea> <p id="d2" style="color:red"></p> </div> </center> </body> </html> Output: By using keydown() and mousedown() method: By using the key-down event and for disabling right-click we use mouse-down() method. With the help of these two methods, we will able to disabled the cut, copy, paste and right-click option. Syntax: $(“selector”).keydown(function) $(“selector”).mousedown(function) Example: javascript <!DOCTYPE html> <html> <head> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script> <style> #geek { padding: 65px 0; } </style> <script> $(document).ready(function() { $(document).keydown(function(event) { // 86 is the keycode of v if (event.ctrlKey == true && (event.which == '86')) { $("#d2").text('paste. not allowed!'); event.preventDefault(); } // 88 is the keycode of x if (event.ctrlKey == true && (event.which == '88')) { $("#d2").text('cut. not allowed!'); event.preventDefault(); } // 67 is the keycode of c if (event.ctrlKey == true && (event.which == '67')) { $("#d2").text('copy. not allowed!'); event.preventDefault(); } // Above all three can be combined into one, above is // executed separately for understanding purposes. /* if (event.ctrlKey==true && (event.which == '86' || event.which == '67' || event.which == '88')) { alert('cut. copy. paste. not allowed!'); event.preventDefault(); } */ }); $('textarea').mousedown(function(e) { if (e.button == 2) { alert('right-click is disabled!'); e.preventDefault(); } }); }); </script> </head> <body> <center> <div id='geek'> <h1 style="color:green">GeeksforGeeks</h1> <p id="d1"> The below textarea won't allow any cut, copy, paste and right-click operations. </p> <textarea></textarea> <p id="d2" style="color:red"></p> </div> </center> </body> </html> Output: Comment More infoAdvertise with us Next Article How to disable Copy, Paste, Cut and Right Click using jQuery ? T Tejashwi5 Follow Improve Article Tags : Web Technologies JQuery jQuery-Misc Similar Reads How to disable right-click option using the jQuery ? The bind() method in jQuery is used to attach one or more event handlers for selected element and this method specifies a function to run when an event occurs. Syntax: $(selector).bind(event, data, function);Parameters: This method accepts three parameters as mentioned above and described below: eve 2 min read Create a Disable Right Click, Copy, Cut & Paste using JavaScript In this article, we have created a simple user interface using HTML and CSS, where there is an input field on which Right-Click, Copy, Cut, and Paste counts are displayed. When the user tries to perform these operations, a warning or error message is displayed, and the counter value is incremented f 3 min read How to disable right click on web page using JavaScript ? Disabling right-click on a web page can be done using the DOM Events. It is a client-side action, and it can be achieved using JavaScript. However, it's important to note that attempting to prevent right-clicking is not a foolproof method for protecting your content, as users can easily bypass it by 2 min read How to make a Disable Buttons using jQuery Mobile ? jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops. In this article, we will be making a Disable Button using jQuery Mobile. Approach: First, add jQuery Mobile scripts needed for your project. <link rel="stylesheet 1 min read How to add dbclick() on right click in jQuery? The jQuery dblclick() method is used to detect whenever a particular element is double-clicked. This method only detects left mouse button double clicks and not the right mouse button double clicks. In this article, we will see how to simulate the double right mouse click in jQuery. Approach: There 3 min read How to Disable Text Selection using jQuery? In this article, we are going to learn how to disable text Selection using jQuery. Disabling text selection refers to preventing users from highlighting or selecting text content on a webpage. Text seÂlection is a common feature in numerous web applications. However, there might arise situations whe 4 min read How to disable a jQuery UI menu? In this article we will disable a jQuery UI menu Syntax: $(".selector").menu( "disable" );Learn more about selectors and menu options in jQuery. Approach: First, add jQuery UI scripts needed for your project. <link href = "https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel = 1 min read How to enable/disable a button using jQuery ? Enabling/disabling a button using jQuery involves altering its functionality to either accept user input or not. This is typically done by manipulating its 'disabled' property or attribute through jQuery methods like `.prop()` or .attr().To enable/disable a button using jQuery, you'll need a basic H 2 min read How to create a Disabled Input using jQuery Mobile ? jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops. In this article, we will be creating a Disabled Input using jQuery Mobile. Approach: Add jQuery Mobile scripts needed for your project. <link rel=âstylesheetâ hre 1 min read How to Disable a Button in jQuery UI ? To disable a button in jQuery UI, we will be using disable() method which is discussed below: jQuery UI disable() method is used to completely disable the button. It returns the button element completely to its initial state. Syntax: $(".selector").button("disable") Parameters: This method does not 2 min read Like