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

Users have to click page before shortcuts can work #60

Open
noahmanger opened this issue Jan 8, 2018 · 4 comments
Open

Users have to click page before shortcuts can work #60

noahmanger opened this issue Jan 8, 2018 · 4 comments

Comments

@noahmanger
Copy link

I'm trying to set up a global shortcut manager that wraps my entire app in order to have shortcuts that navigate to different routes (i.e. hitting c takes you to the compose message view). Is it the intended behavior that the user needs to click somewhere on the page before the shortcuts can fire? Or am I doing something wrong?

@jacqt
Copy link

jacqt commented Apr 11, 2018

Perhaps this may be useful to other people, but I have found that using targetNodeSelector="body" will fix this problem.

@jfrux
Copy link

jfrux commented May 2, 2018

Don't you generally have to make sure the app is focused before shortcuts work in general? Seems like this isn't really anything unexpected? Browsers need that context before input should be listened for. Would be kind of a nightmare otherwise... maybe I'm missing the point of this issue.

@noahmanger
Copy link
Author

@joshuairl , right, you always need the browser app itself is in focus, but if you take Github for example, you don't need to actually click on any part of the DOM for keyboard shortcuts to work.

I'll give targetNodeSelector="body" a try. Thanks!

@Soreine
Copy link

Soreine commented Sep 17, 2020

I'm using mousetrap which binds listeners to the document element by default, and I have noticed that these event listeners will be invoked before the onKeyDown handlers of my React components lower in the tree. So I can't stop the propagation of an event from a child component onKeyDown, it will always be handled first by mousetrap at the document level.

I suspect that doing targetNodeSelector="body" leads to the same kind of problems.

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

4 participants