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

Shortcut API: registered shortcuts swallow DOM KeyboardEvents #2337

Closed
reppners opened this issue Sep 14, 2014 · 2 comments
Closed

Shortcut API: registered shortcuts swallow DOM KeyboardEvents #2337

reppners opened this issue Sep 14, 2014 · 2 comments

Comments

@reppners
Copy link

If a keyboard shortcut is registered via the Shortcut API e.g.

'ctrl+shift+c'

and somewhere on the DOM a listener for 'keydown' is registered ( by using jQuery on(...) )

el.on('keydown', function (e) {
    console.log('you pressed ' + e.which + ' with modifiers');

    if (e.ctrlKey) {
        console.log('ctrl');
    }

    if (e.altKey) {
        console.log('alt');
    }

    if (e.metaKey) {
        console.log('meta');
    }

    if (e.shiftKey) {
        console.log('shift');
    }
});

this event listener will not fire for the key combo ctrl+shift+c even if the focus is on the element where the listener is registered. The node-webkit shortcut listener will execute just fine.

So the event is somehow swallowed by Node-Webkit. Is this on purpose? Can this be fixed easily? If anybody can point me in a direction I will happily try to fix this myself and supply a pull request.

@nknapp
Copy link

nknapp commented Mar 11, 2015

If I understand correctly, you have registered a global keyboard shortcut for "ctrl+shift+c" and afterwards try to listen for the same key-combination on a DOM element.

This is not a nw.js issue, but probably working as intented by the operating system. It would be confusing to the user, if pressing "ctrl+shift+c" had two separate effects, one of them depending on which window has the focus...

Try registering a globale shortcut for e.g. "c" (without modifier keys). Then enter a shell or a text editor and type "c". I've tried that on Linux and I was not able to type "c" anywhere until exiting nw.js. The same happens for every other program that registeres global shortcuts (e.g. Kupfer or Synapse)

@reppners
Copy link
Author

Yes you are right. Thanks for pointing me to that.

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

No branches or pull requests

2 participants