For each press of spacebar, pass keystroke to app and increment input counter I would like for each time user press spacebar, for the script to pass keystroke space to a browser (Firefox) to play a game while counting the number of times spacebar was hit.

How do you do that with AppleScript?
Not with AppleScript, but with Whatpulse. You can see exactly how many times you hit spacebar. When you denote what the amount before you play the game, and check what it is afterward, you have the amount of spacebar hits. And its fun to keep track of your statistics!