jQuery keyup Event

The keyup event fires when a pressed key is released. It is useful when you want to react after the user's key action is complete.

Syntax Top ↑

$( selector ).on( "keyup", function (event) {
    // The pressed key was released.
});

Run Code When a Key Is Released Top ↑

$( function () {
    $( document ).on( "keyup", function (event) {
        alert( "Released: " + event.key );
    });
});

Open the original keyup demo →

Display the Released Key Top ↑

$( document ).on( "keyup", function (event) {
    $( "#d1" ).text(
        "Released key: " + event.key + " | Code: " + event.code
    );
});

Textarea Character Counter Top ↑

The original page uses keyup to count text. That purpose is preserved here, although the input event is usually a better choice for production counters because it also catches paste, drag/drop and other input methods.

$( "#d1" ).on( "keyup", function () {
    const length = $( this ).val().length;
    $( "#d2" ).text( length );
});

Open the original keyup counter demo →

See the full textarea counter tutorial and password validation using keyboard input.

keydown() fires when the key is pressed. keypress() is retained as a legacy topic. The key-hold duration example uses both keydown and keyup.

Video Tutorial on Keyboard Events






plus2net.com






We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2026   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer