event.which
The event.which
property in jQuery indicates the specific key or button that was pressed.
For the mouse event, it report 1 for left button, 2 for middle, and 3 for right.
event.which
property ExampleLog which key was depressed.
$("input[name=username]").keydown(function(e){ var which = e.which; var key = e.key; console.log(key); $('#log').append('<p>The key code is: '+ which +'. key character is: '+key +'</p>'); });