The Clipboard API provides the ability to respond to clipboard commands (cut, copy, and paste) as well as to asynchronously read from and write to the system clipboard.
Instead of creating a Clipboard object through instantiation, you access the system clipboard through the Navigator.clipboard global:
navigator.clipboard
.readText()
.then(
(clipText) => (document.querySelector(".editor").innerText += clipText),
);
function copyInputText(){
const copyText = document.getElementById("myInput");
navigator.clipboard.writeText(copyText.value);
}
Clipboard API
(MDN docs),
Clipboard Events (W3Schools examples)