AutoKey repeating loop

Solution 1:

I have a similar requirement, and from my searching, I found a comment from AutoKey developer.

These codes could be what you need:

while True:
    retCode = keyboard.wait_for_keypress(
        'c', modifiers=['<ctrl>'], timeOut=5)
    if retCode:
        break
    keyboard.send_key("4")