ctrl+n, f5 do not work #159

Open
apobekiaris opened this Issue Sep 22, 2013 · 13 comments

Projects

None yet

8 participants

@apobekiaris
    Mousetrap.bindGlobal('ctrl+n', function () {
        alert('Hi');
        return false;
    });

never called

@ccampbell
Owner

This is working fine for me.

http://jsfiddle.net/8RAxu/

Do you have any other information?

@apobekiaris

I tried your link with both IE and Chrome and a new window is opened instead of the alert. i also tried F5 and the site caught it and asked me if i want to realod instead again of the alert. I do not know how else can i help u

@ccampbell
Owner

I am not binding to F5, but because of the way jsfiddle works you have to first click inside the "Result" pane so that it has focus before pressing ctrl+n.

@apobekiaris

hmm whatever i try i get a new window and for F5 locally i get a refresh. I tried F5 with another framework and works fine

@apobekiaris

is there any piece of code u can give me to test it locally?

@speedy111

ctrl+n on Windows and cmd+n on Mac also doesn't work for me on all browsers. I think it's impossible to support this because it's reserved by the browser. The same holds for mod+w, mod+p, mod+t, mod+q. There are quite some topics on this, e.g.: https://code.google.com/p/chromium/issues/detail?id=33056

If you find a cross-browser workaround then please let me know, but it doesn't seem possible.

@owenversteeg

Doesn't work for me either (Chromium 33 on Arch Linux)

@janmohammadi

Doesn't work for in Chrome and Opera!

@Misiu
Misiu commented Aug 27, 2015

This shortcut is reserved in Chrome (same as Ctrl+T), but for example Ctrl+D works fine (by default in Chrome this calls add to bookmarks dialog).
It would be nice to override Ctrl+N but I guess there isn't a workaround for now.

@ghiculescu

@ccampbell what do you think about having Mousetrap log a warning if you try to bind a shortcut that it knows won't work? I'm thinking a short, hardcoded list - mod+n, F5, mod+t, etc.

I'm happy to write this and submit a pull request if you think it's worth doing. It would have saved me a bit of googling time if Mousetrap said "hey, that binding you just set isn't going to work, and here's why: ".

@kafeltz
kafeltz commented Sep 23, 2015

Isn't just a problem of e.preventDefault() would solve it?

@ghiculescu

No. Chrome doesn't send keystroke events for these key combos at all.

@kafeltz
kafeltz commented Sep 24, 2015

@apobekiaris What is your OS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment