I've got a keyup function for multiple text boxes. How do I trigger the keyup function when someone copy and past something in to the textbox?
.on("click blur keyup", ".emotion", function() {
//match something
});
I've got a keyup function for multiple text boxes. How do I trigger the keyup function when someone copy and past something in to the textbox?
.on("click blur keyup", ".emotion", function() {
//match something
});
Switch the event keyup
for input
, which will trigger whenever something is inputted into the field, even if text is being pasted (both by pressing CTRL + V
or right mouse button » Paste.
.on('input', '.emotion', function() {
// Do your stuff.
});
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">
Use the paste
event. As far as I've tested it works for Ctrl+V pasting, and right-click>Paste pasting.