Hmm, not sure I am answering the question you have asked.
You want to use a keyboard short cut (defined at a OS/Desktop level) and have that passed to a background task ?
Normally, a keystroke (of any sort) is not passed to a background task, so, may, initially seem difficult.
My approach would be to define the keystroke to start the application. Then, use something like IPC to check if there is an existing instance is running and if it is, send a message to it and exit. In your case the message is "user pressed the magic keys".
IPC,
https://wiki.freepascal.org/SimpleIPC allows one process to talk to another. I use it in my app to primarily to ensure only one instance is running in pretty much the behaviour you seek IMHO.
Davo
edit: typo, exit v exist