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 27, 2016, 1:55 AM
Nice share
Gowtham KPosted Jul 26, 2016, 10:28 PM
Nice Share, great clarity in the difference you have shown
Afzaal Ahmad ZeeshanPosted Jul 26, 2016, 9:51 AM
Nice, but the difference could have been great if that was about keypress and keydown. :-)
Anu VPosted Jul 26, 2016, 7:31 AM
Nice