Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Possible to discern when a user shift/ctrl/cmd clicks a link? #17

Closed
benfrain opened this issue Aug 5, 2014 · 3 comments
Closed

Possible to discern when a user shift/ctrl/cmd clicks a link? #17

benfrain opened this issue Aug 5, 2014 · 3 comments

Comments

@benfrain
Copy link

benfrain commented Aug 5, 2014

Would it be easy enough for tappy to discern between 'normal' taps and ones with a modifier key? I realise this isn't an everyday occurrence but since putting tappy on my blog I had someone complain I was click-jacking shift+click, which in their Chrome should have opened the link in a new tab (but opens in the same one with Tappy present).

My JS-fu is weak so I'm short on code offerings :(

I'm thinking along these lines (semi-pseudo code):

if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey || e.ctrlKey)) {
        // Tappy starts here
}
// Source: http://www.jacklmoore.com/notes/click-events/
@scottjehl
Copy link
Member

I suppose that's reasonable, but the use case seems unusual. Is this when touch events are simulated in chrome devtools?

On Aug 5, 2014, at 5:40 PM, Ben Frain notifications@github.com wrote:

Would it be easy enough for tappy to discern between 'normal' taps and ones with a modifier key? I realise this isn't an everyday occurrence but since putting tappy on my blog I had someone complain I was click-jacking shift+click, which in their Chrome should have opened the link in a new tab (but opens in the same one with Tappy present).

My JS-fu is weak so I'm short on code offerings :(

I'm thinking along these lines (semi-pseudo code):

if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey || e.ctrlKey)) {
// Tappy starts here
}

Reply to this email directly or view it on GitHub.

@benfrain
Copy link
Author

benfrain commented Aug 6, 2014

I have Tappy set like the intro docs:

$( "a" ).each( function(){
  var href = $( this ).attr( "href" );
  if( href.indexOf( "#" ) !== 0 ){
                $( this ).bind( "tap", function(){
                    window.location.href = this.href;
                });
            }
} );

I think it's people using the site on desktop/non-touch who ctrl-click to open links in a doc in a new window/tab. I don't do that myself but I know it's not uncommon (I right click and 'open in new tab' for the same effect) but obviously people who left-click with a modifier key aren't being discerned/filtered out by Tappy at the moment which means alll clicks with Tappy bound to them end up in the main window.

It's possible (probable) I just need to amend the way I'm applying it?

@scottjehl
Copy link
Member

Ah, yeah sorry that makes good sense. We should fix this with a little exception.

jefflembeck added a commit that referenced this issue Aug 13, 2014
modifier keys - better protection. fixes #17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants