I want to stop the right mouse button on a HTML5 canvas bringing up the context menu, since it gets in the way of mouse-controlled games.
I’ve tried adding oncontextmenu="return false;" to the canvas tag attributes. This works when the canvas is using a 2D context, but not when it uses a WebGL context, in both Firefox and Chrome.
Is this somehow specified by the standard or is it two simultaneous browser bugs? Is there any way to work around this and block right clicks in a WebGL context?
Results may vary per browser so ensure this works on all targeted browsers. I only tried it in Chrome.
Working example: http://jsfiddle.net/cK9Rt/
(it will say “test” in the console but not make the context menu)