How to Disable Ctrl + C in JavaScript ? Last Updated : 02 May, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report Disabling Ctrl+C in JavaScript involves intercepting the keyboard event and preventing the default action associated with the combination. There are several approaches to disable Ctrl+C in JavaScript which are as follows: Table of Content Using Event ListenersModifying the clipboard eventUsing Event ListenersConnect an event listener to the keydown event for the document or particular elements.When the event is triggered by pressing Ctrl + C, disable the default behavior.Syntax:// Add an event listener to the keydown event for the document or specific elementsdocument.addEventListener('keydown', function(event) { // Check if Ctrl + C is pressed (key code 67) and Ctrl key is also pressed if ((event.ctrlKey || event.metaKey) && event.keyCode === 67) { // Prevent the default behavior (copying) event.preventDefault(); }});Example: To demonsrtate disabling the Ctrl+C in JavaScript using the event listner in JavaScript. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <style> p { font-size: xx-large; font-weight: bold; } </style> <body> <p>This text cannot be copied using Ctrl+C.</p> <script> document.addEventListener('keydown', function (event) { if (event.ctrlKey && event.key === 'c') { event.preventDefault(); alert("Copying is disabled."); } }); </script> </body> </html> Output: Browser's OuptutModifying the clipboard eventIntercept the clipboard event (`copy` event).Prevent the default action of copying the content when `Ctrl + C` is pressed.Syntax:// Add an event listener to the copy event on the document or specific elementsdocument.addEventListener('copy', function(event) { // Prevent the default action of copying the content when Ctrl + C is pressed event.preventDefault();});Example: To demonsrtate disabling the Ctrl+C in JavaScript by modifying the Clipboard event. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> p { font-size: xx-large; font-weight: bold; } </style> </head> <body> <p>This text cannot be copied using Ctrl+C.</p> <script> document.addEventListener('copy', function (event) { event.preventDefault(); alert("Copying is disabled."); }); </script> </body> </html> Output: Browser's Ouptut Comment More infoAdvertise with us Next Article How to Disable Ctrl + C in JavaScript ? P parthdollor Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Similar Reads How to Disable Ctrl+V (Paste) in JavaScript? What is Ctrl + V ?The ctrl+V is a keyboard shortcut used to paste anything from anywhere. It can be disabled for a particular task or page. Let's see how to disable cut, copy, paste, and right-click. To disable the ctrl+V (paste) keyboard shortcut in JavaScript, you would typically capture the keydo 3 min read How to Disable Input in JavaScript ? Disabling input fields in JavaScript is a common task when you want to restrict users from interacting with specific form elements. This can be useful in various scenarios, such as preventing modifications to fields that are conditionally locked or ensuring certain inputs are controlled programmatic 2 min read How to disable JavaScript in Chrome Developer Tools? In many situation, we may find it useful to inspect how a webpage appears without the influence of JavaScript. Disabling JavaScript allows us to observe the baseline functionality and styling of a site. In this tutorial, we'll focus on how to achieve this in Chrome Developer Tools, a powerful toolse 2 min read How to enable JavaScript in my browser ? We will explore the process of enabling JavaScript in web browsers to ensure seamless functionality of applications and websites. JavaScript serves as a fundamental component of modern web development, facilitating dynamic interactions and enhanced user experiences. However, encountering issues wher 2 min read How to Disable and Enable JavaScript in Google Chrome? You may be wondering how a website looks with or without JavaScript. On Chrome, JavaScript is enabled by default, but you can disable it fairly quickly to see the impact on a site's functionality and appearance. Why Should I Enable or Disable JavaScript?Modern websites rely heavily on JavaScript to 4 min read Like