I wrote a simple calculator, after inserting a number into it, it does not perform any operations until I click on an empty space.
Is there no way to display the result as soon as I enter both numbers? Maybe there is a way to run a calculator on a keyboard event like that? tell me how to implement?
(it seems to be there, I just noticed that when I enter the text here, it is broadcast at the bottom without having to click the mouse)
$('.first,.second').change(function() { var a = parseInt($('.first').val()); var b = parseInt($('.second').val()); c = a * b; if (!c) { $('.result').val('0'); } else { $('.result').val(c); } }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> <input class='first' placeholder="введите число"> <input class='second' placeholder="введите число"> <input class='result' readonly="readonly" placeholder="рузультат">