views:

54

answers:

2

Is it possible using some sort of client side code to detect cut and paste?

The only solution I can think of is to constantly get the text length and if it changes drastically over a certain period, then assume text was pasted.

+1  A: 

Yes. Add a keydown event listener and look for keyCode 86 and e.ctrlKey == true. It looks like this has been asked and answered in this post and this post

umop
If the purpose is just to detect if a text was pasted i will use both suggested ways:the one from umop, watching when the V key and control key are pressed simultaneously and if some text have incremented drastically...
Garis Suero
what if you go Edit - Paste from the menu though?
RoboShop
i paste with the middle mouse button
dotjoe
Found another, more exhaustive post. Edited my answer to suit.
umop
+1  A: 

It seems like the only way you'd know if the text changed through all the crazy ways text can be inserted into a textbox might be to monitor the value in an Interval...checking for when the next interval value was different from the previous...that would detect any form of change but it isn't a very neat solution (seems overkill)...

davidsleeps