jQuery Tutorial


jQuery Example


jQuery References


jQuery keypress() Event Reference


  jQuery Events References


Uses

jQuery keypress() event Occurs when key is pressed.


Bind a Function to keypress() event

Defined function run when the keypress() event occurs on the selected elements.

Syntax

$(selector).keypress(function) 

jQuery keypress() events supported following parameters.

ParameterDescription
functionFunction is Optional parameter. Function define the ready to run when event occur.

Example

<script type="text/javascript"> 
$(document).ready(function(){
  $("input").keydown(function(){
    $("input").css("background-color","#FFFF99");
  });
  $("input").keyup(function(){
    $("input").css("background-color","pink");
  });
});
</script>
Online Try This Code Your Self....   »

Trigger the keypress() event

Triggering the keypress() event for a selected elements.

Syntax

$(selector).keypress()

Example

<script type="text/javascript"> 
i=0;
$(document).ready(function(){
  $("input").keypress(function(){
    $("span").text(i=i+1);
  });
});
</script>
Online Try This Code Your Self....   »

  jQuery Events References