'Using JavaScript with OnContextMenu and event.shiftKey at the same time
- I can use OnContextMenu() to detect right-clicks.
- I can use event.shiftKey to detect if the user is holding down the shift key.
- But I can't seem to get BOTH working at the same time, but only in FireFox. (Chrome works fine)
- FireFox just displays the normal right-click menu instead
https://jsfiddle.net/pf1grqx8/
<div style='border:1px solid black; width:555px;' oncontextmenu='return Test(event);'>
Ctrl + rightClick works <br><br>
Shift + rightClick does not work in Firefox (but works ok in Chrome)
</div>
and
function Test(e)
{
alert(e.ctrlKey + "\n\n" + e.shiftKey);
return false;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
