Is there a way to implement in chat “the other user is not typing” when his textarea is empty and “the other user is typing” when the textarea has at least one character?
First, I wanted to implement this “is typing” function by checking every 2 seconds if the user is pressing keys but i’ve realized it would slow the chat too too much. Is it a simple way to pull the info when the textarea is not empty (user is typing) and when empty- do nothing.
Thank you.
Send the “is typing” message on first
keyupand usewindow.setTimeoutto send the “not typing” message after 10 seconds or so. Cancel and reschedule the setTimeout on every keyup.Untested example below: