I am sure its possible, what you are looking for is a python key logger, a logger would write key strokes to an array and then you could make it so that when the user types done etc. it can count how many times something is in the array:
e.g. (Not actual code)
keys_array = ["w","e","a","s","d"]
print(count(keys_array)w)
You would have something like that, it's not actual code and might not work.