Tying button to key stroke

Would this be a script that runs at startup or does it have to run all the time?