copy any text when onclick code example
Example: how to make a button that paste text in a textbox html
<!DOCTYPE html>
<html>
<head>
<script>
function paste() {
var pasteText = document.querySelector("#text");
pasteText.focus();
document.execCommand("paste");
pasteText.value = pasteText.value + pasteText.value;
}
</script>
</head>
<body>
<input id="text">
<button onclick="paste()">Paste</button>
</body>