r/programmingrequests • u/derillianstone • Mar 29 '16
[Request] Making a script that, when I press a key, it records exactly when I pressed it, and totals how many times I pressed it in a given time interval.
Ideally, I could do this in my browser, like Chrome or Firefox. If this concept already exists in some easily-used fashion, maybe someone could point me that way? =)
I'm attempting to monitor frequency of a given event, as well as totaling how many times that event has occurred in an arbitrarily-defined time frame.
So, say I'm watching an experiment that starts at 3:00 PM and runs until 4:00 PM (or some arbitrarily-defined time), and I'm looking out for some event that I will track by hand by pressing the Spacebar on my keyboard or something.
At the end, I'd like an output that tells me how many times I pressed my button in that time interval, and maybe an average "# of events per minute" or something. Ideally I'd just get a data dump of the event and its associated time stamp starting from when I started running the script, and I can try and figure out other data from it.
Thanks! =D
4
u/LenAnderson Mar 30 '16
Save the following code as an .html file, open it and start pressing keys... Best to use Chrome as Firefox does not have a nice direct text representation for all keys.
The counting table and the raw log should allow for copy-pasting into Excel or similar applications.