textfield detect when user start typing and stop typing

Hi
how i can detect when user start typing and stop typing.

i need to run a function after user stop typing on the textfield

Define what you mean by “stop typing”. That the user hasn’t typed anything for one second? Two? Five?

What exactly do you want to do when the user stopped typing?

Markus has a very good point. Technically, one stops typing after each character. Typing is not a continuous event.

Perhaps what you want is to call the function when the textfield loses focus? Surely, when the user moves away from the textfield, he is done typing.

Or start (or reset) a Timer on every keystroke. When the user “stops typing”, as defined by the Timer’s period, the Timer will run.

I do what Kem does. When the user presses a key I check to see if the timer is already running. If not, start it. If so, reset the accumulated value. Then, if the user stops typing the timer action fires and I can then do something with the text. Works reasonably well though you might have to adjust the timer period based on how fast you think they’ll be typing.

If memory serves, this is what the search field in the Navigator is doing. If no typing has been seen for a half second or so it performs the search. As long as you are typing it won’t initiate the (sometimes) lengthy search.

FYI, if you set the Timer.Mode to Single or Multiple, if the Timer was already running, it is reset even if you are setting it to the same mode.

I never rely on that and call Reset anyway, but just something to be aware of.

ok
thanks to all for the ideas