title: How to copy without user click
body: <p>Im using tampermonkey to make a script in js to copy and password and open the site for that password so i can easily paste it in. However, I am having some trouble with the copying part. from what i see there is a need user interaction to copy something and i understand this is for security purposes and people dont want random things going into their clipboard. Is there a way to turn this off in my browser (Chrome). If not i have one more idea. I use a key combo (CTRL <em>DOWN ARROW</em>) to activate the script to copy and open a new tab and i use that user interaction to copy the text.</p>
  
  <p>This is what i have so far</p>
  
  <pre><code>(function() {
    'use strict';
  
    function KeyPress(e) {
      var evtobj = window.event ? event : e
      if (evtobj.keyCode == 40 &amp;&amp; evtobj.ctrlKey) {
        var aTags = document.getElementsByTagName("td");
        var searchText = "WP-Admin Password";
  
        //Finding The Password
        var pass;
        var found1;
        for (var i = 0; i &lt; aTags.length; i++) {
          if (aTags[i].textContent == searchText) {
            //found 1 is the element that has the search phrase
            found1 = aTags[i];
            //This is where im trying to copy to my clipboard the text content.
            found1.nextSibling.firstChild.textContent; //wp Admin Password
            ;
  
            break;
          }
        }
        //Finding a Dev url if they have one
        var pass3;
        var found3;
        var dev;
        for (var k = 0; k &lt; aTags.length; k++) {
          if (aTags[k].textContent == "Development URL") {
            found3 = aTags[k];
            if (found3.nextSibling.firstChild.firstChild !== "") {
              found3.nextSibling.firstChild.firstChild.click();
            } else {
              dev = false;
            }
            break;
          }
        }
        //fining the live url and going to it
        var pass2;
        var found2;
        if (!dev) {
          for (var j = 0; j &lt; aTags.length; j++) {
            if (aTags[j].textContent == "Website") {
              found2 = aTags[j];
              found2.nextSibling.firstChild.firstChild.click();; //url
              break;
            }
          }
        }
      }
    }
    document.onkeydown = KeyPress;
  })();
  </code></pre>