8 ms·
Ask HN: Why don't web apps make use of right click?
I only recently found out about "oncontextmenu", which is a javascript event that fires when a user right clicks a web page. Using that event, you can prevent the OS/browser right click menu, and even create your own menu.
So my question is: why don't more web apps make use of that? A right click is an operation that's instilled in many (all?) computer users, why not leverage that instead of having complicated dropdown options menus?
- andriesm 10y agoWe make use of right-clicks EXTENSIVELY, almost any and everything in TaskPutty.com is clickable. Of course our app is designed to make every single widget or thing user modifiable and configurable.
- Cozumel 10y agoYou answered your own question, 'I only recently found out about "oncontextmenu"', not a lot of people (outside of tech) seem to know about it, also not everyone uses a mouse!
- garyadamshannon 10y agoAnswer: How do you right click on a phone? A proportion of people are designing mobile first, desktop displays are second priority.
- _RPM 10y agoGoogle Drive makes use of `oncontextmenu` and also Outlook does too.
- _RPM 10y agoIt's been in use since the 90's people would attach the event to images, and assert copyright in an alert dialog on the event callback: Array.prototype.forEach.call(document.getElementsByTagName('img'), function(value) { value.oncontextmenu = function() { alert("Get off my lawn!"); } });
- yakult 10y agoOne problem is usually you have to disable the built-in menu. The built-in menu does some pretty important things and as an end user I basically never want it disabled.
- edpichler 10y agoThis is the right answer (on my belief).
- csmattryder 10y agoI completely 100% agree, but it'd be nice to be able to append to a small sub-group "Webpage Settings" that'd allow you to drop a few additional items in the menu. I think we're at this point, especially with mobile getting analogue touch sensitivity via "Force Touch" on iOS. Of course, to prevent overzealous developers, the title strings must not share the same name one of the existing static items. Let's learn from letting our less wise colleagues alter scroll behaviour.
- robgibbons 10y agoOftentimes, web users are already habituated to the use of default right-click context menus in browsers, at least for most web pages. Oncontextmenu is certainly great for some applications, which is why it's there, but it can damage usability if it's abused. Whenever I visit a site with right-click events, I think back to the early days of the web, when webmasters tried to prevent you from viewing their source by capturing right-clicks (then you just had to use the menu bar).
- marpstar 10y ago1. It's extra work that only "power users" will benefit from. 2. No support on mobile?
- wingerlang 10y agoThank god they don't. I hate it when I try to right click to do something and I get some custom control with like one or two options I don't even want.
- p333347 10y agoIt is bad form to block default UI,and it will only annoy and anger your users. The solution to this is to append your own menu to the default context menu. However, this cannot be done AFAIK. Probably a standard that allows that would be something worthy of consideration. So the only way to deal with this is custom UI elements. (As a Windows desktop developer moving to web development, I was quite dismayed that I couldn't simply get menu handle and append. In general, moving to straight jacketed webapps from desktop background where almost everything was possible was quite frustrating and painful.)
- jklein11 10y agoIt looks like you can extend the context menu of chrome[1], safari[2], IE[3], and firefox[4]. 1.https://developer.chrome.com/extensions/contextMenus https://developer.chrome.com/extensions/contextMenus 2.https://developer.apple.com/library/content/documentation/Tools/Conceptual/SafariExtensionGuide/AddingContextualMenuItems/AddingContextualMenuItems.html https://developer.apple.com/library/content/documentation/To... 3.https://msdn.microsoft.com/en-us/library/aa753589(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/aa753589(v=vs.85).a... 4.https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Add_a_Context_Menu_Item https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Ad...
- p333347 10y agoYes but I was talking about a standard that doesn't depend on idiosyncrasies of different browsers and their ecosystems.
- raquo 10y agoUI needs to be predictable and discoverable, right click on web pages is neither. People in general either don't use right click, or expect the browser context menu to show up. So if you hide important UI controls behind right click, many users won't find them.
- csallen 10y agoI believe it's a cycle: Web developers don't make use of right-clicking, so users don't expect to use it and never try, so web developers don't use because it's not discoverable, and so on.