Is it possible to intercept and modify text that gets pasted into a textarea?
If intercepting isn't possible, can I modify it after being pasted? (Without modifying the already present text in the textarea.)
With jQuery:
jQuery(function($){
$('#your_element').bind('paste', function(event){
event.preventDefault();
var clipboardData = event.originalEvent.clipboardData.getData('text/plain');
console.log(clipboardData);
});
}
});
Works in IE and Webkit. With Firefox you might have to use this:
http://intridea.com/2007/12/16/faking-onpaste-in-firefox?blog=company
Maybe intercept keypress
es, to know when CTRL+C is pressed, cache current text, then at CTRL+C's keyup
, check current value against cached one, with simple text processing you can know the new text, and do whatever you want with, and update accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With