<!DOCTYPE html>
<html>
<body>
<p>This example uses the addEventListener() method to attach a "copy" event to an input element.</p>
<input type="text" id="myInput" value="Try to copy this text">
<script>
document.getElementById("myInput").addEventListener("copy", myFunction);
function myFunction() {
alert("You copied text!");
}
</script>
</body>
</html>