After spending some time searching, decided to combine few existing pieces of code and write the rest from scratch.
This is a starting point and possibly can be improved in many ways. Please let me know your suggestions in the comments.
-Works with input and textarea items, by adding the class ‘InputContainer’
-Automatically saves every 20 seconds of none-stop typing
-Automatically saves after 2 seconds of no typing
-Saves when clicked out of the text box
-Saves before closing the page
-Activates the autosave while typing and deactivates afterwards to avoid overloads
-Every save operation resets the timer to makes sure different autosave points don’t conflict or save too many times
Feel free to use/change the code as you need.
Thanks to Christian C. Salvadó for the typewatch code.