OSX - Button spam help?
It looks like there's an app that does what you want. Keyboard Maestro allows you to set one key to repeat, a configurable delay and a second key to configure to stop the automation.


http://leancrew.com/all-this/2016/03/dont-forget-simple-automation/ 


The link above is how to configure the app for paging through a 2,000 page long PDF and stop when a key is pressed, but you could easily adopt that workflow for your game I think.