Skip to content

coreyadam8/copyguard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛡️ copyguard-js

A lightweight JavaScript utility to block copying, pasting, cutting, and right-clicking.

copyguard-js provides a simple, framework-free way to prevent users from copying content, opening the context menu, or pasting into inputs. It can be used to secure form fields, protect sensitive data, or discourage content scraping.


🚀 Features

  • 🔒 Block Ctrl+C (Copy), Ctrl+V (Paste), Ctrl+X (Cut)
  • 🖱️ Disable right-click (context menu)
  • 🧠 Optional onViolation callback for custom behavior/logging
  • 🪶 Zero dependencies

📦 Installation

npm

npm install copyguard-js

Then in your JavaScript:

import Copyguard from 'copyguard-js';

Copyguard.enable({
  blockCopy: true,
  blockPaste: true,
  blockCut: true,
  blockRightClick: true,
  onViolation: (type) => {
    console.warn(`Blocked: ${type}`);
  }
});

CDN

<script src="https://unpkg.com/copyguard-js@latest/dist/copyguard.min.js"></script>
<script>
  Copyguard.enable({
    onViolation: (type) => {
      alert(`🚫 ${type} blocked`);
    }
  });
</script>

🧪 Example

Copyguard.enable({
  blockCopy: true,
  blockPaste: true,
  blockCut: true,
  blockRightClick: true,
  onViolation: (action) => {
    console.log(`User tried to: ${action}`);
  }
});

// To disable protection:
Copyguard.disable();

🌐 Live Demo

View a demo at: https://coreyadam8.github.io/copyguard


📄 License

MIT License © Corey Adam


🔗 Links

About

A tiny JavaScript library to block copy, paste, cut, and right-click actions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors