title: Javascript timeout when no actions from user for specified time
body: <p>I want to call a js function when there is no activity from user on the web page for specified amount of time. If there is activity from user then reset timeout. I tried to search but couldn't find anything in particular. I am familiar with setTimeout() and clearTimeout() and how they work. What I am looking for is where/how to monitor for user activity.  Is there any event in which I can set and clear timer? </p>
  
  <p>Thank you. </p>
  
  <p>Edit #1:</p>
  
  <p>This webpage has one input text box &amp; one button. It's kind of regular chat page. When I say no user activity, I mean that the user has not typed anything in text box or has not pressed any button for specified amount of time. <strong>And one more thing that it is targeted for touch based smartphone devices.</strong></p>
  
  <p>Edit #2:</p>
  
  <p>Thank you everyone for suggestions. I've implemented solution based on more than one answers provided. So I will give upvote to all answers that I've found helpful instead of accepting one as answer.</p>