jQuery Tutorial Tutorials - jQuery event.which

jQuery 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.

jQuery event.which property Example

example

Log 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>');
});

Try now

Date:2019-08-29 19:03:32 From:www.Lautturi.com author:Lautturi