Here we are going to explain what is keypress() event or how to use keypress() event or why to use keypress() event with example.


The jQuery keypress() event is executed when a keyboard button is pressed down. This event is similar to keydown() event. The keypress() method is executed or attach a function to run when a keypress() event occurs.

  • Syntax:

Trigger the keypress event for the selected elements:



  • Example of jQuery keypress() event

Let's see an example to of jQuery keypress() event.

<!DOCTYPE html>
<html xmlns="">
    <title>jquery keypress tutorial</title>
    <script src="Scripts/jquery-1.8.2.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("input").keypress(function () {
                $("#content").css("color", "red");
    Write something: <input type="text">
    <p id="content" style="margin-top:10px; width: 300px; height: 88px; color:#fff;">



Use jQuery keypress event

I hope it will help to you.

 Let's check live example

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like