How to change the hold time requirement for TouchLongPress event?

Is it possible to adjust the hold requirement for the TouchLongPress event and set it to fire once the player taps and holds their screen for a given time? Is this event predefined to a set value that you cannot modify and should I just use the TouchStarted event instead?

1 Like

If there was, it’d be somewhere on the UserInputService page. Unfortunately that kind of property or method doesn’t exist, the time is calculated internally. Probably not even by UserInputService but by the actual device software.

Answer: you don’t.

Only way around it is to handle this interaction yourself by firing an event after a few seconds if TouchEnded has not yet been fired. Might want to implement a Promise for such a thing.

4 Likes

Alright thanks for clearing some stuff up!

Why do you need to use a promise? You could simply check when the touchBegins and then check if the TouchEnded time is after the long hold time requirement.

You don’t have to use a Promise but it’s something that you can look into if you want. Promises have this kind of workflow built-in and if you’re networking your code (e.g. a framework or dependence on a library loader), then you’ll have that utility available for you. It’d also help for consistency around your codebase.

If you’re looking for a simple solution though without Promises, then yeah, I would do that as well - I already do it for a few of my systems. I’m going off of the assumption that OP still wants to keep the native TouchLongPress behaviour though so an event would fire after a certain amount of time. Knowing when the user releases their finger wouldn’t exactly be relevant here: that’d be a different case altogether.

1 Like

With my case it would still be on a timer and can still run specific tasks after a certain amount of time passes.

When I said “with my case” what I meant was logging the TouchBegan time.