Skip to content

Instantly share code, notes, and snippets.

@inter-coder
Last active November 14, 2017 13:12
Show Gist options
  • Save inter-coder/52eddc9822c3a2d86a521350063c1de9 to your computer and use it in GitHub Desktop.
Save inter-coder/52eddc9822c3a2d86a521350063c1de9 to your computer and use it in GitHub Desktop.
Copy to clipboard as typing
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