How to achieve key down "laziness"

Use case:

  • I have a search field where a user can enter search terms.
  • Search terms shall be converted automatically (in “realtime”) into a where condition for a database access to show matching items. Matching items shall be updated as the user types

Expected behavior:
I don’t want that the database is accessed too frequently during typing. So, I want to introduce a “laziness” of let’s say 1 second, where the user can go on typing, but the next search in the database is not happen before 1 second after the previous search.

I tried the OnKeyDown-event and put a wait(1000) statement in there. The system is then waiting for that period, but key down events are stacked and then executed with a 1 second delay from event to event.
What I would like to have is that I can specify a “laziness” where no key down event is fired for a certain period, or that the event is canceled within this period.

Any idea how to achieve this?

Regards,

Hi @Klaas_Klever,

this should do the trick:

Let me know if it works for you.

Cheers
Stanislaw

Hi @stanislaw.grin ,
Not exactly what I’ve imagined, but it’s doing the job!
No search is done until the user stopped typing (“stop” is a break of 1000 ms). That’s ok for my use case. Thanks!

I guess a “timer” is something which is running on the client only, not on the server, right?

Regards,

If we’re talking about UI Builder, then yes, timer will run on the client side.
But it is also possible to use timers on the server side (using Codeless Business Logic) for other cases.