Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger a JavaScript action when shift-double clicking

I am moving from Safari to Chrome and desperately miss the Safari zoom behavior. There's an extension dblclickzoomin that makes things zoom like safari whenever you doubleclick. However, this is supremely annoying! I double click to select full words of text, etc.!

Can I modify the code to make it work when I hold shift and double click?

The trigger bit of the code is:

init: function(){
      window.addEventListener("dblclick",Zoomer,false);
    }, 

Since shift-dblclick (or better, shift triple click) isn't a standard DOM trigger... does anyone have any ideas?

Thanks!!

like image 803
user2362191 Avatar asked May 15 '26 16:05

user2362191


1 Answers

Use the event.shiftKey property to determine if the Shift key was depressed during double-click:

window.addEventListener("dblclick", function(e){
    if(e.shiftKey) {
        Zoomer.apply(this, arguments); // call Zoomer with same `this` and args
    }
}, false);
like image 97
apsillers Avatar answered May 17 '26 05:05

apsillers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!