I'm using htmlarea for my little CMS, and I was wondering if it's possible to detect if something gets pasted into it with jQuery?
Asked
Active
Viewed 532 times
1 Answers
1
Try adding an Event Listener to your textarea for "keydown," and then looking out for keyCode == 86, that's the paste event. Now you can do whatever you want to happen when a user tries to paste.
Like this:
document.getElementById('YOURhtmlArea').addEventListener('keydown',
function (foo)
{
if (foo.keyCode == 86)
{
alert('SOMEONE IS PASTING');
foo.preventDefault();
}
});
I hope that helps.

Peter Mortensen
- 30,738
- 21
- 105
- 131

cazlab
- 788
- 5
- 17
-
1
-
1Not sure how, but ckEditor handles this. You could start tearing apart their code, it is open source. – Dustin Laine Mar 04 '10 at 19:58