You can use the following Javascript to disable the context menu except when activated with Alt+RightClick.
function f(ev) { if (!ev.altKey) { ev.preventDefault(); return false; } }
document.addEventListener('contextmenu',f, false)
With Pentadactyl
Since you're running pentadactyl, you can simply add the following lines to your .pentadactylrc
:
:js function f(ev) { if (!ev.altKey) { ev.preventDefault(); return false; } }
:js document.addEventListener('contextmenu',f, false)
Notes
This will only work if the Firefox setting dom.event.contextmenu.enabled
is set to true
. This is the default value, so it should be fine unless you (or an extension) have changed it.
If it's been set to false
, you need to change it. You can do this by opening the page about:config
in Firefox, searching for the entry and double-clicking to toggle it. Alternatively, in Pentadactyl, execute the command
set! dom.event.contextmenu.enabled=true
If you want to remove the block, the can use the Javascript function
document.removeEventListener('contextmenu',f)
So in Pentadactyl, :js document.removeEventListener('contextmenu',f)