Last active
November 14, 2017 13:12
-
-
Save inter-coder/52eddc9822c3a2d86a521350063c1de9 to your computer and use it in GitHub Desktop.
Copy to clipboard as typing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelector("input").addEventListener('keyup',function(){ | |
var pom=document.createElement("textarea"); | |
document.body.appendChild(pom); | |
pom.value=this.value; | |
pom.select(); | |
try { | |
document.execCommand('copy'); | |
pom.parentNode.removeChild(pom); | |
this.focus(); | |
} | |
catch (err) { | |
console.log(err); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment