I have on
change
trigger that gets the event :
$(document).on('change', '.class', function (eve) {
How can I know if the change is from the mouse or from the keyboard by the event variable?
No, that is not possible because a change
event may only fire when the concerned element loses focus, after several changes were made with several different input methods, including mouse and keyboard.
Test it with this input
element: enter some text with keyboard, paste some text using the context menu (right click), and maybe move some characters by dragging them with the mouse into a different position. Then press the button. Only now you get the change
event:
$(document).on('change', '.class', function (eve) {
console.log('change event occurred');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input class="class">
<button>Button</button>
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