Detect Keystoke in c# windows application

  • Thread starter Thread starter Josh
  • Start date Start date
J

Josh

Hi,
I want to detect the keystroke entered by the user in my
application. Actually the scenarion is, at first the user is entering
some details to the windows form, later on he is idle for few minutes
..That time there is no keystroke detected to my form.If there is no
keystroke detected for more than 10 minutes then i have to close the
form.how to incorporate this., any suggestions.

Thanks in advance
Josh
 
Hi Josh,

You could add a KeyPressed handler to the form , you will also need a
timer, the idea is to reset the timer each time a keystroke is received, you
could call Stop() and later Start() on the timer or use Enabled instead ,
this will reset the timer to 10 min after the last keystroke, then if the
timer handler is ever called you will know that 10 minutes passed without a
KeyPress.


Hope this help,
 
Back
Top