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
});
keyup / keydown seem to only work on elements that are present at document. ready . If you are triggering your event from elements that were altered or injected post pageload, these events will not fire.
The keyup event is fired when a key is released. The keydown and keyup events provide a code indicating which key is pressed, while keypress indicates which character was entered. For example, a lowercase "a" will be reported as 65 by keydown and keyup , but as 97 by keypress .
The keyup() is an inbuilt method in jQuery which is used to trigger the keyup event whenever User releases a key from the keyboard. So, Using keyup() method we can detect if any key is released from the keyboard. Syntax: $(selector).keyup(function) Here selector is the selected element.
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">
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