WiFi LoRa 32 (V3) Assigning PRG Button

I’m currently writing an Arduino Sketch which will transmit a CW signal using the LoRa radio. It is set to loop, all of which is working fine, however, I’d like to assign the PRG button as a TX Enable/Disable button, so that I can stop the loop if I need to, effectively turning the TX off and then restarting it when I push the PRG for a second time.

I can’t seem to get this to work. Any input from the PRG button seems to be being ignored. Can anyone suggest how I might resolve this issue, or can the PRG button not be assigned for runtime toggling?

Thanks,

Dom