When a completion function takes a long time, I can interrupt it by pressing Ctrl+C (terminal interrupt key, sends SIGINT) or Ctrl+G (bound to
send-break). I am then left with the uncompleted word.
However, if I happen to hit Ctrl+C or Ctrl+G just as the completion function finishes, my key press may cancel the command line and give me a fresh prompt instead of cancelling the completion.
How can I set up zsh so that a certain key will cancel an ongoing completion but do nothing if no completion function is active?