Search code examples
javascriptcross-browsersamplemousewheelright-click

Special mouse events in a browser: wheel, right-click?


Google maps is an impressive display of what you can do with JavaScript and Ajaxy-goodness. Even my mouse scroll wheel and right-click works to provide specific functionality.

In the standard HTML spec, I don't see an onmouserightclick event or similar basic JavaScript handling for the mouse wheel. Maybe I am looking in the wrong places.

I presume these events are browser and platform-specific (or "sensitive" instead of specific). And am wondering what the basic, plain HTML and JavaScript are needed to exploit these events, in ALL browsers.

Naturally, when designing a site these features have to be extra since some people still use the one-button mouse.

How to I use events with the mouse wheel and right-click? I'm looking for sample code.

EDIT: Thanks for the jQuery code guys! The system-developer in me still has questions and doubts though. Mainly I'm concerned about platform-limitations that would seem to apply here. Is there a browser that some of these features don't work in? Does the mouse wheel up and down events also allow for mouse wheel click events? I would just expect there to be some limitation out there and am wondering if it's officially documented. I want to know how it works at a low level. I am glad to see it is easy in jQuery, another reason for me to get into it.


Solution

  • Mouse Wheel:
    ol' no-jquery-or-prototype-library method: here

    Prototype method: Here

    JQuery method: Here