Example

Show which key was pressed:

$("input").keydown(function(event){
  $("div").html("Key: " + event.which);
});

Try it yourself »

Definition and Usage

The which property specifies which key or button was pressed for the event.

This property can be used on key and button events.

Syntax

event.which

Parameter Description
event Required. Specifies the event to check. The event parameter comes from the event binding function