A different approach - subclassing WKWebview, measuring the time between pastes and if they're too close, reject the second attempt.
class WebView: WKWebView {
var previousPasteTimestamp: TimeInterval = .zero
override func paste(_ sender: Any?) {
let currentPasteTimestamp: TimeInterval = Date().timeIntervalSinceReferenceDate
if currentPasteTimestamp - previousPasteTimestamp < 0.2 {
print("prevent double paste")
return
}
previousPasteTimestamp = currentPasteTimestamp
super.paste(sender)
}
}