News for hackers. Stuff that matters.

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?

( 20 comments | 8 points | on HN )
Re:Ask HN: Why don't web apps make use of right click? by yakult on Tuesday September 20, 2016 @08:10PM (#12544443)
One 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.
Re:Ask HN: Why don't web apps make use of right click? by csmattryder on Wednesday September 21, 2016 @11:42AM (#12549220)
I 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.

Re:Ask HN: Why don't web apps make use of right click? by edpichler on Tuesday September 20, 2016 @08:54PM (#12544634)
This is the right answer (on my belief).
Re:Ask HN: Why don't web apps make use of right click? by garyadamshannon on Tuesday September 20, 2016 @07:48PM (#12544328)
Answer: How do you right click on a phone?

A proportion of people are designing mobile first, desktop displays are second priority.

Re:Ask HN: Why don't web apps make use of right click? by Avalaxy on Wednesday September 21, 2016 @04:24AM (#12546349)
The touch equivalent of a right click is a long press.
Re:Ask HN: Why don't web apps make use of right click? by Garvey on Friday September 23, 2016 @07:42AM (#12563816)
Can't it also be a two finger tap?
Re:Ask HN: Why don't web apps make use of right click? by wingerlang on Wednesday September 21, 2016 @12:37AM (#12545439)
Thank 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.
Re:Ask HN: Why don't web apps make use of right click? by robgibbons on Tuesday September 20, 2016 @10:27PM (#12544977)
Oftentimes, 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).

Re:Ask HN: Why don't web apps make use of right click? by _RPM on Tuesday September 20, 2016 @07:56PM (#12544359)
It'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!"); 
        }
    });
Re:Ask HN: Why don't web apps make use of right click? by mod on Thursday September 22, 2016 @11:37AM (#12557595)
They used to do it on mousedown, so then you could hold the mouse down, click enter to dismiss the alert, and then release the mouse, and get the menu anyway.

The internet used to suck a lot worse than it does now.

Re:Ask HN: Why don't web apps make use of right click? by joshmn on Wednesday September 21, 2016 @01:15AM (#12545593)

  alert("hotlink protection!!1");
Re:Ask HN: Why don't web apps make use of right click? by p333347 on Wednesday September 21, 2016 @08:52AM (#12547695)
It 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.)
Re:Ask HN: Why don't web apps make use of right click? by jklein11 on Wednesday September 21, 2016 @02:16PM (#12550789)
Re:Ask HN: Why don't web apps make use of right click? by p333347 on Wednesday September 21, 2016 @02:44PM (#12551054)
Yes but I was talking about a standard that doesn't depend on idiosyncrasies of different browsers and their ecosystems.
Re:Ask HN: Why don't web apps make use of right click? by Cozumel on Tuesday September 20, 2016 @07:33PM (#12544257)
You 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!
Re:Ask HN: Why don't web apps make use of right click? by raquo on Wednesday September 21, 2016 @03:26PM (#12551402)
UI 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.
Re:Ask HN: Why don't web apps make use of right click? by csallen on Wednesday September 21, 2016 @08:09PM (#12553343)
I 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.
Re:Ask HN: Why don't web apps make use of right click? by andriesm on Tuesday September 20, 2016 @07:05PM (#12544105)
We 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.

Re:Ask HN: Why don't web apps make use of right click? by marpstar on Tuesday September 20, 2016 @10:28PM (#12544982)
1. It's extra work that only "power users" will benefit from. 2. No support on mobile?
Re:Ask HN: Why don't web apps make use of right click? by _RPM on Tuesday September 20, 2016 @07:54PM (#12544348)
Google Drive makes use of `oncontextmenu` and also Outlook does too.