Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm creating an application that sits in the background and records all key presses (currently this is done and working; an event is fired every keydown/keyup). I want to offer a feature for the user that will show them their WPM over the entire session the program has been running for. This would be easy if I added a "Start" and "End" button to activate a timer, but I need to detect only when the user is typing continuously - ignoring all one-time keyboard shortcuts and breaks the user takes from typing.

How in the world do I approach this? Is this even realistically & accurately possible?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

You could simply have a built-in in timer delay function which fires when a given time has passed since the last key-press. Once the user starts typing again, the timer un-pauses and continues. The given timer could be something like 2 seconds, which is a reasonable delay for most computer literate people. Once the timer starts again, just subtract that 2 seconds given time from the timer so the WPM isn't thrown off.

Keyboard shortcuts may be the harder issue. Something like every keypress event fires a lookup in a table somewhere checking to see if a keyboard shortcut was pressed do nothing, if not, increment the global character counter.

share|improve this answer
1  
Sounds good, thank you very much! –  Scott Kaye Nov 2 '13 at 17:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.