Introduction
This blog describes the difference between Keypress and Keyup, in jQuery.
Keypress
- For each Keypress, we will get the previous value. The first value of Keypress is null.
Keyup
- For each Keyup, we will get the current value.
Code
Html
- Enter your name:
- <input type="text" id="name"> Enter your place:
- <input type="text" id="place">
- <p>Name: <span id="fullname"></span></p>
- <p>Place: <span id="placename"></span></p>
- $(document).ready(function() {
- $("#name").keypress(function() {
- // alert($("#name").val());
- document.getElementById('fullname').textContent = $("#name").val();
- });
- $("#place").on("keyup", function() {
- document.getElementById('placename').textContent = $("#place").val();
- });
- });


kalu singh raoPosted Jul 26, 2016, 9:55 PM EDT
Nice share
Gowtham KTOP 100Posted Jul 26, 2016, 6:28 PM EDT
Nice Share, great clarity in the difference you have shown
Afzaal Ahmad ZeeshanTOP 100Posted Jul 26, 2016, 5:51 AM EDT
Nice, but the difference could have been great if that was about keypress and keydown. :-)
Anu VPosted Jul 26, 2016, 3:31 AM EDT
Nice