Home >>jQuery Tutorial >jQuery event.which Properties

jQuery event.which Properties

jQuery event.which Properties

jQuery event.which property in jQuery is used to returns which mouse button or keyboard key was pressed for the event.

Syntax:
event.which

Parameter Values

Parameter Description
event It is a required parameter and is used to specify the event parameter comes from the event binding function
Here is an Example of jQuery event.which Property:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("input").keydown(function(event){ 
$("div").html("Key:" + event.which);
});
});
</script>
</head>
<body>
Enter your Fname: <input type="text">
<p>The div element below will display the key number, When you type in the field above</p>
<div/>
</body>
</html>

Output:
Enter your Fname:

The div element below will display the key number, When you type in the field above


No Sidebar ads