- Forum >
- Topic: Troubleshooting >
- Detect 'control + click/comma…
Detect 'control + click/command + click'
This goes for really any Duolingo application specific href – please detect 'command + click' so that I can open main nav links, discussion topics, etc... in a new tab without having to 'Right click → Open in new tab'. I am often paginated into the discussion list and accidentally command click a topic expecting it to spawn a tab and lose my place.
kthxbye!
http://stackoverflow.com/questions/10910554/how-to-detect-command-shift-click-for-os-x-in-javascript
22 Comments
10
Copy-pasting in my report from the previous discussion of this at http://www.duolingo.com/comment/1025495 :
Yes, I've noticed this too -- ctrl-click used to work at some point, but it changed a while ago. For reference, I've just tested ctrl-click with:
- Chrome 30.0.1599.101 on Ubuntu 12.04 64-bit
- Firefox 24.0 on Ubuntu 12.04 64-bit
- Chrome 30.0.1599.101 m on Windows XP SP3 32-bit (VirtualBox, 64-bit Ubuntu host)
All these browsers open links in new tabs on ctrl-left-click, except within the main duolingo.com website, where the link replaces the content in the current tab (i.e. same behaviour as left-clicking with no modifier keys). For example, links from http://blog.duolingo.com/ open in new tabs if Ctrl is held down.
I personally would be keen to see this fixed. Most touchpads don't have a middle button so it makes the website (especially the forums) less convenient to use on a laptop.
dqxxmvyvoedn
Odd - there was this discussion (http://www.duolingo.com/comment/576069) which indicated to me that it was working in Chrome 29, but perhaps it went back to not working in 30. I'll look into it more - thanks for the report (and the follow up investigations =P).
For what it's worth, I just tested on Firefox and Safari (Mac 10.8.2 both latest browser stable) and experienced the same behavior – command+click failed to spawn a new tab, rendering the resource in the same window via xhr.
Rather than a browser bug, I have a feeling it is due to the nature of the click event handling within Duolingo's single page architecture. Just a thought, but maybe add some event handler logic to allow the browser to natively handle this specific key combo rather than preventDefault() + submitting the async request (as noted here http://stackoverflow.com/questions/10660360/command-click-doesnt-open-a-new-tab-but-middle-click-does, which I think accurately addresses this).
This isn't a huge deal, but would be nice for those of us who are link-spawn-trigger-happy :)
Another similar note about this behavior with a similar resolution here http://stackoverflow.com/questions/10910554/how-to-detect-command-shift-click-for-os-x-in-javascript.
Just need to add a simple method like the below pseudocode to determine whether or not to handle the route in Backbone or native browser...
function followLink(e) {
..If command+click used (e.metaKey || e.ctrlKey)
....let the browser handle it natively
..else
....preventDefault
....navigate link via Backbone router
}
As an experiment, I just pasted the links from the top navbar into a bare-bones html file with no scripts. The hashes in the URLs had zero effect on ctrl-click behavior in Chrome (Version 31.0.1650.57 m) or in Firefox (25.0.1), yet they don't work correctly from the main Duo page. This supports chrisfay's suggestion that this is probably an event handling issue rather than a browser compatibility issue.
Another bit of evidence: ctrl-clicking any user's profile on this forum page will not open in another browser tab, yet there are no hashes in any of those URLs.
10
This has been reported previously, at http://www.duolingo.com/comment/1025495 . Unfortunately, judging by the lack of comments or upvotes on that report, not many people are troubled by this behaviour, so I'm not sure that there's much chance of it getting changed.
2653
Confirmed. Really annoying (Chrome, Mac)! I don't click anything without "right"-click and "open in new tab". Otherwise everything will be gone.
10
Yes, middle click does usually work -- however, this is difficult or impossible to do with many trackpads.
I use the scroll wheel too, and I have experienced the same problem a few times. It is especially annoying when I middle-click a user name in discussion or some other link and it works like a normal left-click bringing me away from the unfinished lesson :-( In the same situation, right-click + Open in new tab always worked correctly.
For me, this bug usually disappeared after I refreshed the page. I also have to admit that I got it rather long ago for the last time.
I've included this behavior in my Duolingo Modifications userscript, for anybody who is interested: https://www.duolingo.com/comment/1738577
It's still an issue for me. Ctrl-Click does not work, Mouse Middle-Click does open in new tab.
But it's selective. Eg. the for external links line the two in chrisfay's original post it's OK, but for Duolingo page links (my name, top menu items, etc.) won't work.
I'm on WinXP + Chrome (v33.0.1750.154 m)