Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key shortcuts clash with Chrome #6563

Closed
sadikyalcin opened this issue Apr 11, 2018 · 3 comments
Closed

Key shortcuts clash with Chrome #6563

sadikyalcin opened this issue Apr 11, 2018 · 3 comments
Labels

Comments

@sadikyalcin
Copy link

Operating System : OSX

I first noticed this years ago with the Escape button on fullscreen. If you bind the same shortcuts as Chrome, the shortcuts on Chrome stops working. Really annoying bug!

I wanted to bind a reload to Command/Control R like Chrome has - pretty standard.

I believe it depends on what you have open first. If you don't have chrome running the bind will work on nw.js but if you have both running - it won't work in neither.

If you quit nw.js - it still won't run on chrome. You will have to restart it and it may work.

This was an issue with all versions but for the record I'm using 0.29.4.

var gui = require('nw.gui');
var key;

if( device == 'osx' ){
  key = 'Command+R';
} else {
  key = 'Ctrl+R';
}

var option = {
  key : key,
  active : function() {
    console.log("Global desktop keyboard shortcut: " + this.key + " active."); 
  },
  failed : function(msg) {
    console.log(msg);
  }
};

var shortcut = new gui.Shortcut(option);
gui.App.registerGlobalHotKey(shortcut);

(Edit: I now can't bind the shortcut on osx)

Error: Unable to register the hotkey
    at Function.Shortcut.registerGlobalHotKey (extensions::nw.Shortcut:204)
    at Object.bindingsAPI.compiledApi.registerGlobalHotKey (extensions::nw.App:117)
    at <anonymous>:12:9
@Christywl
Copy link
Contributor

I can't reproduce this issue on Mac with nwjs-sdk-v0.29.4.

  1. Open chrome browser first, press 'Command + R', the page is reloaded
  2. Start nwjs app and open the devtools
  3. Press ‘Command +R’, Global desktop keyboard shortcut: Command+R active output in the console
  4. Press 'Command + R' again in chrome browser, the page is not reloaded
  5. Close the nwjs app, press 'Command + R' again in chrome browser, the page is reloaded

@sadikyalcin
Copy link
Author

sadikyalcin commented Apr 16, 2018

Press 'Command + R' again in chrome browser, the page is not reloaded

This is exactly part of what I'm talking about. Is this normal behaviour? As that is not what I'm after. Shouldn't the shortcuts be relative to the focused application?

I can't replicate the issue where it doesn't work in both at the moment. But it does happen sometimes (it is random). Especially with the Esc key to exit fullscreen.

In the video below, you can see nw.js shortcuts are trigged while focused on chrome.

Video

@sadikyalcin
Copy link
Author

Ok - I have my facts wrong silly me.

Shortcut represents a global keyboard shortcut, also known as system-wide hotkey. If registered successfully, it works even if your app does not have focus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants