Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8211121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:19:19+00:00 2026-06-07T10:19:19+00:00

As I have heard, different browsers assign different keycode values to mouse buttons on

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:19:20+00:00Added an answer on June 7, 2026 at 10:19 am

    With jQuery, 2 will 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 than 2 on f.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:

    // Add which for click: 1 === left; 2 === middle; 3 === right
    // Note: button is not normalized, so don't use it
    if ( !event.which && button !== undefined ) {
      event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this script in the head of my index.html. I want different scripts
I am having problems passing javascript values between frames in chrome. In other browsers
I have a head file which I am using for a few different pages.
We have a Prepared Statement in Java and we hear that it is different
I have heard that when dealing with mutexes, the necessary memory barriers are handled
I have heard a lot of people in the Magento community mention the benefits
I have heard that in C++, using an accessor ( get...() ) in a
I have heard it many times that garbage collection in PyS60 is not up
I have heard that web-based chat clients tend to use networking frameworks such as
I have heard that GTK covers all controls so that developers do not care

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.