Yep, I stop spamming by using global variables. In this case, I use a global variable 'Active', which is set to False by default.
When Key is pressed, If 'Active' is False > Set 'Active' to True, Do Action, Wait 2 seconds, Set 'Active' to False. This will only allow key presses when 'Active' is set to false.