Would suggest not to mix jQuery and pure JavaScript. All you need is to add the keyup keydown instead of input:

$('table input').on('keyup keydown', function() {
  var parent = $(this).closest('tr');
  var value = parent.find('[name="item_value[]"]').val();
  var amount = parent.find('[name="quantity[]"]').val();
  var total_cost = value * amount;
  parent.find('[name="total_cost[]"]').val(total_cost);
  total_value = total_value + total_cost;
  $('#total').val(total_value);
});
Answer from Praveen Kumar Purushothaman on Stack Overflow
🌐
W3Schools
w3schools.com › jsref › event_onkeyup.asp
onkeyup Event
The onkeyup event occurs when the user releases a key on the keyboard. ... The onkeypress event is deprecated. It is not fired for all keys (like ALT, CTRL, SHIFT, ESC) in all browsers.
🌐
W3Schools
w3schools.com › tags › att_onkeyup.asp
HTML onkeyup Attribute
The onkeyup attribute is part of the Event Attributes, and can be used on any HTML elements. Execute a JavaScript when a user releases a key: <input type="text" onkeyup="myFunction()"> Try it Yourself » · ❮ Previous All HTML Attributes Next ❯ · ★ +1 · Sign in to track progress ·
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Element › keyup_event
Element: keyup event - Web APIs | MDN
The event target of a key event is the currently focused element which is processing the keyboard activity. This includes: <input>, <textarea>, anything that is contentEditable, and anything else that can be interacted with the keyboard, such as <a>, <button>, and <summary>. If no suitable ...
🌐
jQuery
api.jquery.com › keyup
keyup event | jQuery API Documentation
Show the event object for the keyup handler (using a simple $.print plugin) when a key is released in the input.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › javascript tutorial › javascript onkeyup
JavaScript onkeyup | How onkeyup Event work in JavaScript | Examples
May 22, 2023 - Also, onkeypress sees the keys having letters or digits, whereas onkeyup handles all the keys on the keyboard. ... In our first example, we will see JavaScript code append 1 to each letter being pressed in the input field.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
CodePen
codepen.io › andersz-artur › pen › doXOZr
Input onkeyup
<input id="myField" type='text' onkeyup='alertMe(this.id);'> <div class='output'> Your value: <span id='myOutput'></span> </div>
🌐
Mathias Byens
mathiasbynens.be › notes › oninput
Using the oninput event handler with onkeyup/onkeydown as its fallback · Mathias Bynens
May 11, 2011 - HTML5 standardizes the oninput event handler, which should be used to detect user input in JavaScript. Sure, you could use onkeydown or onkeyup instead, but those were never really designed for this particular use case, and it shows.
🌐
JavaScript.info
javascript.info › tutorial › browser: document, events, interfaces › ui events
Keyboard: keydown and keyup
We’ll cover it later in the chapter Events: change, input, cut, copy, paste. Keyboard events should be used when we want to handle keyboard actions (virtual keyboard also counts). For instance, to react on arrow keys Up and Down or hotkeys (including combinations of keys). To better understand keyboard events, you can use the teststand below. Try different key combinations in the text field. ... kinput.onkeydown = kinput.onkeyup = kinput.onkeypress = handle; let lastTime = Date.now(); function handle(e) { if (form.elements[e.type + 'Ignore'].checked) return; area.scrollTop = 1e6; let text = e.type + ' key=' + e.key + ' code=' + e.code + (e.shiftKey ?
Find elsewhere
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
addEventListener ('Keyup') vs HTML attribute 'Onkeyup'
November 7, 2021 - I want to restrict an input text through a regular expression. In the first example I use the attribute onkeyup = “lettersOnly(this)” inside the HTML, as follows: <form> <label for="username">Choose a Username:</label> <…
🌐
Scaler
scaler.com › home › topics › javascript onkeyup
JavaScript onkeyup - Scaler Topics
May 4, 2023 - Javascript onkeyup() event is a type of event which occurs when the user presses any key on the keyboard and just after the user leaves the key (key up) onekeyup event takes place.
🌐
W3Schools
w3schools.com › tags › ev_onkeyup.asp
HTML onkeyup Event Attribute
Tip: The order of events related to the onkeyup event: ... Enter your name: <input type="text" id="fname" onkeyup="myFunction()"> <script> function myFunction() { let x = document.getElementById("fname").value; document.getElementById("demo").innerHTML = x; } </script> Try it Yourself »
🌐
GeeksforGeeks
geeksforgeeks.org › html › html-onkeyup-event-attribute
HTML onkeyup Event Attribute - GeeksforGeeks
August 5, 2025 - The HTML onkeyup event attribute executes JavaScript code when a user releases a key after pressing it within an input field or textarea, enabling dynamic responses to keyboard input.
🌐
Willmaster
willmaster.com › library › tutorials › onkeydown-onkeyup-onclick-and-onchange-javascript-events.php
OnKeyDown, OnKeyUp, OnClick, and OnChange JavaScript Events
<form style="margin:0;"> <p style="margin:0;"><b>A:</b> onkeydown -</p> <input type="text" id="onkeydown" style="width:148px;" onkeydown="AnEventHasOccurred()"> <p style="margin:0;"><b>B:</b> onkeyup -</p> <input type="text" id="onkeyup" style="width:148px;" onkeyup="AnEventHasOccurred()"> <p style="margin:0;"><b>C:</b> onchange -</p> <select id="selectone" onchange="AnEventHasOccurred()"> <option value=""></option> <option value="Green">Green</option> <option value="Gold">Gold</option> <option value="Silver">Silver</option> </select> <p style="margin:0;"><b>D:</b> onchange -</p> <input type="
🌐
W3Schools
w3schools.com › jquery › event_keyup.asp
jQuery keyup() Method
Set the background color of an <input> field when a keyboard key is released: $("input").keyup(function(){ $("input").css("background-color", "pink"); }); Try it Yourself » · The order of events related to the keyup event: keydown - The key is on its way down ·
🌐
GeeksforGeeks
geeksforgeeks.org › html › html-dom-onkeyup-event
HTML DOM onkeyup Event - GeeksforGeeks
July 12, 2025 - The HTML DOM onkeyup event in HTML occurs when a key is released after pressing by the user.