control-freak-ide/Control-Freak-Documentation/jQuery/docs/entries/event.which.json
plastic-hub-dev-node-saturn 538369cff7 latest
2021-05-12 18:35:18 +02:00

1 line
1.5 KiB
JSON

{"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<input id=\"whichkey\" value=\"type something\">\n<div id=\"log\"></div>\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<input id=\"whichkey\" value=\"type something\">\n<div id=\"log\"></div>\n"}],"longdesc":"\n <p>The <code>event.which</code> property normalizes <code>event.keyCode</code> and <code>event.charCode</code>. It is recommended to watch <code>event.which</code> for keyboard key input. For more detail, read about <a href=\"https://developer.mozilla.org/en/DOM/event.charCode#Notes\">event.charCode on the MDC</a>. </p>\n <p><code>event.which</code> also normalizes button presses (<code>mousedown</code> and <code>mouseup</code>events), reporting <code>1</code> for left button, <code>2</code> for middle, and <code>3</code> for right. Use <code>event.which</code> instead of <code>event.button</code>. </p>\n "}]}