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

How to handle key events when I have global listeners? #297

Open
PEZ opened this issue Jun 28, 2023 · 2 comments
Open

How to handle key events when I have global listeners? #297

PEZ opened this issue Jun 28, 2023 · 2 comments

Comments

@PEZ
Copy link

PEZ commented Jun 28, 2023

Thanks for providing this component!

I want to control an animation with the slider. So I have only one slider. I want the same things to happen when I press keys like right or left when the slider has focus as when it doesn't have focus. Currently I can control the animation with keys. The slider also has event handlers for the keys, and as I want to control the animation from the slider, it gets to be a double command that I don't know how to deal with. Anyone has some pointers for me?

Possibly related:

@msf-caesar
Copy link

Try with removing the event handlers for key events from the slider component. Instead, add a global event listener that listens for key events regardless of focus. In the event handler for the key events, check if the slider has focus. If it does, control the animation accordingly. This way, you can have consistent control over the animation whether the slider has focus or not.

@PEZ
Copy link
Author

PEZ commented Sep 1, 2023

Thanks! 🙏 In my case it seems like removing the event handlers for the keys. Will start there.

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