简体   繁体   中英

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!!

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM