You can add an onpaste event handler to the element receiving the paste event.
In the handler you should:
- Add a delay (there are multiple ways to do this)
- Return true so the default handler continues with the pasting operation.
For example:
var myElement = document.getElementById('pasteElement');
myElement.onpaste = function(e) { //Add handler to onpaste event
doSomethingHere(); //Do something before the delay
sleep(200); //Add the delay
return true; //return true continue with default paste event
}
//One way to introduce a delay
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
EDIT: Added a line to show where to perform the action before the wait.