As I have heard, different browsers assign different keycode values to mouse buttons on mousedown event. I have tried this in Chrome and it worked:
$('a').mousedown(function(f) {
if (f.which == 2) {
alert("You clicked the wheel")
}
})
However, I’m afraid some browsers will fail to recognize the mousewheel’s keycode being 2 and will confuse it with the other mouse buttons, thus crashing the code. My question is if there is any way to reset these values so I can use the new ones I provide so all the browsers will know what the numbers represent exactly.
With jQuery,
2will represent the mouse wheel or the «middle click button». You cannot change these values, but you also do not have to, because if you get something other than2onf.which, it’s most likely not the mousewheel that was downed.There are two mouse event models, one by the W3C and one by Microsoft.
Browsers (also including IE7 and IE8) implement the W3C standard.UPDATE
In Javascript, the mouse event button is not normalized because of the two different standards. Actually, jQuery normalizes the which on the mouse event: