I know that I will need to implement something that will keep the hook alive
No, it's not a problem. A global hook requires a DLL with a callback. This DLL is injected into all running processes. It will remain loaded in the process until you name UnHookWindowsHookEx (), or the process ends, whichever comes first.
Please note that you can also connect the keyboard using WH_KEYBOARD_LL. This is not a global hook; Windows will switch the context to your program and make a callback. This is much easier to use, since you do not need the IPC mechanism with the embedded DLL that the global hook requires. The low-level hook remains active until you unhook it, the thread that owns the message queue ends, or your process ends, whichever comes first.
source share