How to Disable All Hotkeys (F12, CTRL+U, CTRL+Shift+C) on Blogger and WordPress

How to Disable All Hotkeys (F12, CTRL+U, CTRL+Shift+C) on Blogger and WordPress

🚨 Prevent Unwanted Access to Your Website's Code 🚨

If you're a website owner, you may want to protect your site's content and code from being inspected or copied. Disabling hotkeys like F12, CTRL+U, and CTRL+Shift+C can help prevent users from viewing your source code or using browser developer tools. Here's how you can achieve this for both Blogger and WordPress websites!


Step 1: Add Custom JavaScript Code

Use the following script to disable key combinations:

document.addEventListener("keydown", function (e) {

  // Disable F12

  if (e.keyCode === 123) {

    e.preventDefault();

    alert("Inspect Element is disabled!");

  }

  // Disable Ctrl+Shift+I, Ctrl+Shift+J, Ctrl+U, Ctrl+Shift+C

  if ((e.ctrlKey && e.shiftKey && (e.keyCode === 73 || e.keyCode === 74 || e.keyCode === 67)) || (e.ctrlKey && e.keyCode === 85)) {

    e.preventDefault();

    alert("Key combinations are disabled!");

  }

});


For Blogger:

  1. Go to your Blogger dashboard.

  2. Navigate to Theme > Edit HTML.

  3. Paste the above script before the closing </body> tag.

For WordPress:

  1. Log in to your WordPress dashboard.

  2. Go to Appearance > Theme Editor.

  3. Add the script to the footer.php file before the closing </body> tag.


Step 2: Disable Right-Click (Optional)

To further enhance security, disable right-click with this code:

document.addEventListener("contextmenu", function (e) {

  e.preventDefault();

  alert("Right-click is disabled!");

});


Follow the same steps above to include this code on your website.


Step 3: Test Your Website

After adding the scripts, test your site to ensure all restricted functionalities are working. Remember, while these measures can deter casual users, advanced users may still bypass these restrictions.


🔐 Protect your content and stay secure! 🌐

Safelik Convert by ProTemplates
Done