{"name":"event.which","type":"property","title":"event.which","deprecated":null,"removed":null,"desc":"For key or mouse events, this property indicates the specific key or button that was pressed.","categories":["events/event-object","version/1.1.3"],"entries":[{"return":"Number","signatures":{"added":"1.1.3"},"examples":[{"desc":"Log which key was depressed.","code":"\n$( \"#whichkey\" ).on( \"keydown\", function( event ) {\n $( \"#log\" ).html( event.type + \": \" + event.which );\n});\n","html":"\n\n
\n"},{"desc":"Log which mouse button was depressed.","code":"\n$( \"#whichkey\" ).on( \"mousedown\", function( event ) {\n $( \"#log\" ).html( event.type + \": \" + event.which );\n});\n","html":"\n\n\n"}],"longdesc":"\nThe event.which property normalizes event.keyCode and event.charCode. It is recommended to watch event.which for keyboard key input. For more detail, read about event.charCode on the MDC.
event.which also normalizes button presses (mousedown and mouseupevents), reporting 1 for left button, 2 for middle, and 3 for right. Use event.which instead of event.button.