I have looked at many posts but could not find a clear current answer to the following two questions as it seems standards and browser support has been constantly changing.<
You can also just turn it into a function that calls its own handler and removes it
function copyStringToClipboard (string) {
function handler (event){
event.clipboardData.setData('text/plain', string);
event.preventDefault();
document.removeEventListener('copy', handler, true);
}
document.addEventListener('copy', handler, true);
document.execCommand('copy');
}