Key automation at X interval

Is there a way I can automate a key being fired? For example, press “1” every X seconds?