5

I know one should use both, event.button and event.which as a safe side for cross-browser compatibility concern.

But still, I am puzzled. I am not able to comprehend the exact context where I should use which mouse event property, MouseEvent.button or MouseEvent.which, and where should I avoid the one.

Also, the quirks associated with different browsers(eg the values associated with those)

Well organized comprehensive details will be greatly appreciated.

Jake
  • 244
  • 2
  • 16
  • 1
    Nowadays, you should use `MouseEvent.button*s*` (note the plural "s"), and `.which` is only needed as a fallback on Safari. See this answer: https://stackoverflow.com/a/48970682/1869660 – Sphinxxx Jun 20 '18 at 21:07

1 Answers1

3

From Mozilla:

https://developer.mozilla.org/en/docs/Web/API/MouseEvent/which

Non-standard This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

https://developer.mozilla.org/en/docs/Web/API/MouseEvent/button

It seems you shouldn't use MouseEvent.which

I can't find much more information on it

Mokkun
  • 708
  • 4
  • 14
  • I somewhere heard that there's also some context where MouseEvent.which is mandatory as MouseEvent.button is not supported or associated with quirks. I couldn't recall exact context. Any advice in this? – Jake May 10 '17 at 09:29