To override the default browser right-click menu, the first step is to prevent the default right-click behavior. This can be done by listening to the contextmenu event and using the preventDefault() method on the event.
A context menu is a pop-up menu that provides shortcuts for actions the software developer anticipates the user might want to take. In a Windows environment, the context menu is accessed with a right mouse click.
Right-click on the “shell” key, and then choose New > Key from the menu. Give the new key the name that you want to show up on the desktop context menu. For this example we'll be using Notepad.
I want my website to have a custom interaction when the user right clicks on an element, <div class="myElement"></div>
. Thus, I don't what the context menu to also pop up when the element is right clicked as to not spoil the UX. Is there a way to do this (preferably in CSS, but vanilla js works too)?
Desired:
.myElement {
contextMenuOnRightClick: none,
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With