Latest web development tutorials

jQuery event.which property

jQuery Event Methods jQuery Event Methods

Examples

Returns which keyboard key is pressed:

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

try it"

Definition and Usage

event.which property returns the specified event which keyboard key or mouse button is pressed.


grammar

event.which

参数 描述
event 必需。 event 参数来自事件绑定函数。


Examples

More examples

Returns which mouse button is pressed
Which mouse button is pressed on the display specified event.


jQuery Event Methods jQuery Event Methods