I have an html form which includes a textarea box and a submit button that calls the API (say the Google Translate API, or Twitter API).
Now I wish to get rid of the submit button and automatically call the API once the user has entered input.
I also wish to have a limited number of API calls: ideally just one API call once the user has finished typing in that textarea.
What would be your recommendation on:
- the language to use (javascript, php, other)?
- the process: what triggers the API call?
Any pointer would be appreciated.
Edit -> About the “finished typing” part: I will never know if the user has finished typing. The only thing I might know is that there is no typing since x seconds. It would be great if I can detect inactivity since 1 or 2 seconds and trigger the API call. Is that possible and how?
PoltoS has given you information about keyUp and setTimeout. Also you can handle onBlur() event. Form is submitted using submit() method of the form. See examples here. BTW you will probably find the sample for all parts of your question there.