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

Keyboard events dont fire unless you are focussed on a form input #1795

Closed
bakesteve opened this issue Jul 7, 2014 · 5 comments
Closed

Keyboard events dont fire unless you are focussed on a form input #1795

bakesteve opened this issue Jul 7, 2014 · 5 comments

Comments

@bakesteve
Copy link

When binding to KeyUp, events only fire if a form input has focus
That prevents various scenarios, like keyboard navigation of a list / grid, and also things like keyboard shortcuts.

Fiddle to demo this is:
http://jsfiddle.net/JXwWC/

I can understand there may be performance reasons for this, and couldnt see the code that caused this, but be great if this can change (and happy to submit a PR if someone points out where the choice to only bind if focussed is happening

@sophiebits
Copy link
Collaborator

Yes, that's how key events work in JS – what you want is to bind to key events on window, which we don't currently have a way to do. Closing as a dupe of #285.

@browniefed
Copy link

If you want to do this sort of thing the Wiki -> Complementary tools links to https://github.com/jhudson8/react-events which will be able to more easily bind to window keypress events in the class context you expect

@bakesteve
Copy link
Author

@spicyj thanks for the quick reply.
On key events, adding a tab index does make a HTML element valid for js key events (rather than just using window)
here is a working example
hence thinking this may be possible without the full solution in #285
@browniefed cheers - I'd seen that plugin and happy using a plugin / workaround, just be nice to do it the react way. On the react-events plugin, I'm also keen to avoid people falling back to bad habbits using react in a backbone-esque way. But thats probably more of a stylistic thing than anything else

@sophiebits
Copy link
Collaborator

@bakesteve Setting tabIndex="0" in React has the same effect.

@bakesteve
Copy link
Author

eh - I was SURE I tried that!
Anyways, here is an updated jsfiddle to prove me wrong: http://jsfiddle.net/JXwWC/1/

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

3 participants