You can do this using Ajax and the onkeypress event plus some kind of counter.
So, you connect the function to the onKeyPress event of your text field, which increases the counter every time it starts, when this number reaches 3 or 4, you set the ajax function, which sends the form to the server in the background and then reset the counter again.
This will cause the form to be published in the background for every third or fourth keystroke that occurs while using a text field, which is each keystroke - space, input, backspace, etc.
source share