How to Add a Read-only Textbox With Text in it That Has a Button to Copy it?

Here is a simple example from w3 schools that uses a bit of JS to copy the value of a input field.

<input type="text" value="StackExchange WordPress" id="myInput">
<button onclick="myFunction()">Copy text</button>

<p>The document.execCommand() method is not supported in IE9 and earlier.</p>

<script>
function myFunction() {
  var copyText = document.getElementById("myInput");
  copyText.select();
  document.execCommand("Copy");
  alert("Copied the text: " + copyText.value);
}    
</script>

Source found here: w3schools