0

Possible Duplicate:
Is right click a Javascript event?

I'm searching an JavaScript event, i can use for the addEventListener('event',...) method.

I know there is click and dblclick. but is there an equal event for right click and for double right click?

Community
  • 1
  • 1
Loki
  • 4,065
  • 4
  • 29
  • 51
  • 2
    No, there isn't: [Is right click a Javascript event?](http://stackoverflow.com/questions/2405771/is-right-click-a-javascript-event). – Felix Kling Nov 18 '12 at 20:43
  • ACK, and it could only be a *DOM* event at any rate. – PointedEars Nov 18 '12 at 20:47
  • Ok, so i can check the double click the way seen in the link. But is there a possible way to check the right click on the document.addEventListener method? Because I really need this Event and the normal click event is not triggered by right click – Loki Nov 18 '12 at 20:51
  • 3
    A double right click? Why do you hate your users so much? – mu is too short Nov 18 '12 at 20:59
  • It's for private purpose only. – Loki Nov 18 '12 at 21:02

1 Answers1

2

First of all, a click is triggered by a click, which is basically a mousedown followed by a mouseup in the same place, of the primary mouse button (usually left).

A right-click does not count as a click for the purposes of the event. However, it still registers mousedown and mouseup events, and you can check the Event.which property to see if it's the right mouse button being pressed. Alternatively, you may be able to use oncontextmenu, which in some cases can be considered the same as a right-click.

That still leaves the problem of a double-right-click, though. For this to work, you would need to measure the time between two right-clicks, and if you deem it short enough to be a double click, then handle it as such. It's a very complex setup, but double-right-clicks are not user-friendly at all so perhaps you should consider an alternative input?

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
  • 1
    This is nothing for a User ;) It should be an chrome-addon for me. I used the add on "Double Click closes Tab" for firefox where i set up the double richt click to close my tab. And on Chrome it doesnt work. I wanted to get it to work again – Loki Nov 18 '12 at 20:54