Advertisement
KyleCypher

CopyPasteYWOT

Sep 18th, 2019
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function() {
  2.     var ctrlDown = false,
  3.         ctrlKey = 17,
  4.         cmdKey = 91,
  5.         vKey = 86,
  6.         cKey = 67;
  7.     $(document).keydown(function(e) {
  8.         if (e.keyCode == ctrlKey || e.keyCode == cmdKey) ctrlDown = true;
  9.     }).keyup(function(e) {
  10.         if (e.keyCode == ctrlKey || e.keyCode == cmdKey) ctrlDown = false;
  11.     });
  12.     $(".no-copy-paste").keydown(function(e) {
  13.         if (ctrlDown && (e.keyCode == vKey || e.keyCode == cKey)) return false;
  14.     });
  15.     // Document Ctrl + C/V
  16.     $(document).keydown(function(e) {
  17.         if (ctrlDown && (e.keyCode == cKey)) {
  18.             $($(".active-cursor")[0]).html($($(".active-cursor")[0]).html() + "<textarea id='textclip'>" + $($(".active-cursor")[0]).html() + "</textarea>");
  19.             document.getElementById("textclip").focus();
  20.             document.getElementById("textclip").select();
  21.             document.execCommand("copy");
  22.             $($("#textclip")[0]).remove()
  23.         }
  24.     });
  25. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement