سؤال

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى softwareengineering.stackexchange
scroll top