I guess you need to look at this from operating system scope not nw.
For example, if it is Linux box, i would monitor /dev/input/mice for any mouse movement, and /dev/input/eventX for keyboard activity.
In windows, i belive it is a bit more complicated, i guess i would write (with google help, becouse im not C# programmer) some app using C# hooks, which would present
keyboar and mouse activity to a text file and then the rest nw code would be the same as in Linux. But again, im not a Windows guy so maybe is a better way.