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

Enter and Space should activate long presses #6337

Open
jamiebuilds opened this issue May 6, 2024 · 1 comment
Open

Enter and Space should activate long presses #6337

jamiebuilds opened this issue May 6, 2024 · 1 comment

Comments

@jamiebuilds
Copy link

Provide a general summary of the feature here

Enter and Space are both used as alternatives in usePress(). However, keyboard events are explicitly filtered out from useLongPress(). The documentation does warn that you should provide an alternative, which makes sense given that some users will not be able to hold a key easily.

But there's still a use case for allowing Space and Enter to perform a long press, for example it's a common interaction for "temporary pausing" such as a in carousels or 'Stories' features in many social apps.

🤔 Expected Behavior?

Space and Enter should activate long presses

😯 Current Behavior

Space and Enter do not activate long presses

💁 Possible Solution

No response

🔦 Context

Had to reimplement useLongPress() in order to get this behavior

💻 Examples

No response

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

@snowystinger
Copy link
Member

Are those actually long presses? I tried Stories with touch, and it pauses until the press is ended. But long press finishes after about half a second, which would be a different behavior. If you used useLongPress for this, it'd only pause the video for half a second and then it would resume. Seems like useLongPress isn't the right thing to use for this interaction pattern to begin with?

It also doesn't take a long press for the keyboard version of the interaction, just a quick tap of the 'Space' key will pause a video.

Maybe you can provide more details about what you're building, or an example app? Maybe some interaction patterns are being conflated. For instance, I think you can just use usePress with onPressStart and onPressEnd and use the interaction mode to determine what actions to take.

Something along these lines?
Touch: pause on press start, resume on press end
Mouse: toggle pause on press
Keyboard: toggle pause on press

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