'How do I make a hotkey on Numpad0, but make Numpad0 work as before?

I wrote this code:

Numpad0::
{
    Loop
    {
        Send {Numpad0}
        Sleep, 10
        if !GetKeyState("Numpad0", "P")
            break
    }
    return
}

Numpad0 & Numpad1::
{
    Send {Volume_Down 1}
    return
}

Numpad0 & Numpad2::
{
    Send {Volume_Up 1}
    return
}

It works. But if you press Numpad0 and hold it, it will write only one character. It should be a loop. Why does the loop not work?

Program version: 1.1.33.11.



Solution 1:[1]

Not sure. I tried something like this once years ago, just to see repeat rate. Maybe try?:

~Numpad0::
While (getKeyState("Numpad0", "P") {
    Send, {Numpad0}
}

Not sure why that would be different, but the tilde allows pass through of the hotkey to the active window instead of just capturing it like usual.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 T_Lube