Starting the lock function when copying and pasting

I have a keyup function for multiple text fields. How to call keyup function when someone copies and skips something in a text box?

.on("click blur keyup", ".emotion", function() { //match something }); 
+6
source share
3 answers

Switch the keyup event for input , which will be keyup whenever something is entered into the field, even if the text is inserted (both by pressing CTRL + V and the right mouse button). Paste.

 .on('input', '.emotion', function() { // Do your stuff. }); 
+11
source

This will do what you want:

 $("#editor").on('paste', function(e) { $(e.target).keyup(); }); $("#editor").on('keyup', function(e) { alert('up'); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="text" id="editor"> 
+3
source

Use the paste event. As far as I tested, it works to paste Ctrl + V and right click> Insert Paste.

+1
source

Source: https://habr.com/ru/post/987503/


All Articles