Detect middle button click (scroll button) with jQuery

Well after a quick test it seems that the three are ordered as follows:

  • Left – 1
  • Middle – 2
  • Right – 3

So if you had:

$(document).mousedown(function(e){
    switch(e.which)
    {
        case 1:
            //left Click
        break;
        case 2:
            //middle Click
        break;
        case 3:
            //right Click
        break;
    }
    return true;// to allow the browser to know that we handled it.
});

Leave a Comment