Check if a “shift” event has occurred from the keyboard

I have a on changetrigger that receives an event:

  $(document).on('change', '.class', function (eve) {

How do I know if a change from a mouse or keyboard has changed to an event variable?

+4
source share
2 answers

To make sure the event is coming from the keyboard, use keydown. To make sure this comes from the mouse, use mousekeydown. Therefore, you will need to register 2 different events for each device:

$(document).on('keydown', '.class', function (e) {
   // From keyboard
}
$(document).on('mousekeydown', '.class', function (e) {
   // From mouse
}
0
source

, , change , , , .

input: , ( ) , , , . . change:

$(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>
+1

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


All Articles