electron / electron

:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
https://electronjs.org
MIT License
114.41k stars 15.44k forks source link

Global shortcut API: add support for meta-key / windows-key #1395

Closed FunkMonkey closed 9 years ago

FunkMonkey commented 9 years ago

It is currently not possible to assign global shortcuts to a windows-key-combination.

Thanks!

anaisbetts commented 9 years ago

Assigning shortcuts to the Windows key is a pretty bad idea in general, Explorer owns that key and very often changes / claims new shortcuts with different OS releases

FunkMonkey commented 9 years ago

I agree that there is a certain chance of collisions, but...

a) I believe there is a higher chance of accidentally overriding application-specific shortcuts with a global shortcut like ctrl+alt+b than with a windows-key-shortcut (even the global-shortcut documentation overrides ctrl+x globally in its example...)

b) I don't believe atom-shell should enforce its beliefs about what good shortcut-combinations are and what not upon the developers and users (especially if users can choose shortcuts themselves - they should not be restricted in the way they want to customize their applications and can make their own informed decisions). This is even more true in terms of point a).

c) Not sure, but I believe reserved windows-key-shortcuts can not be easily overwritten anyway, but have to be disabled first in the registry.

zcbenz commented 9 years ago

Windows forbids overriding many Win global shortcuts, to override them the program has to install keyboard hooks or low level drivers, there is no normal way to work around the limitation.

I'm closing this as won't fix.

FunkMonkey commented 9 years ago

@zcbenz: Not wanting to install keyboard hooks is absolutely reasonable and I'd also argue against that. My intention was not to be able to override existing win shortcuts, but to be able to use the ones that are free (which including shortcuts with multiple modifiers are still a lot).

Considering shortcut collisions between applications may exist with and without the win key, I don't think the win key should be treated any different than ctrl or alt. Trying to register a global shortcut that already exists in the system should always throw an exception anyway (again: no matter whether win or not).

Independent of the state on Windows, Linux users should be able to use a meta key like the win key.

Having said all that, implementing the behaviour seems complicated at the moment anyway, as Chromium's accelerators don't provide win key support and the win modifier is also not passed to Windows' RegisterHotKey function from the GlobalShortcutListener... Thus I guess Chromium would need to be updated first...

zcbenz commented 9 years ago

@FunkMonkey I didn't realize the Win is ignored in GlobalShortcutListener, it makes sense to add support for it.

muelphil commented 3 months ago

As there currently was no solution to register hotkeys including the Win key, I created a native node module to handle this: global-hotkey. You can find it by following this link.

jdms754 commented 3 months ago

As there currently was no solution to register hotkeys including the Win key, I created a native node module to handle this: global-hotkey. You can find it by following this link.

The repository is private - can you please make it public?

muelphil commented 3 months ago

The repository is private - can you please make it public?

The repository is now public - thanks for pointing it out! Please note that it is under development. If you encounter any issues, please let me know.