At which point does a typical keylogging program hook into the keyboard input?  Say some evil person was able to get a hidden keylogger past my hopefully secure defenses.  Now I pull up plain old notepad and hit 'a'.  What happens, programmatically?  Does the keylogger intercept the WM_KEYDOWN event before notepad or after or simultaneously?
Could someone give me a basic step-by-step process?  It certainly does not need to be detailed as I have no intentions of writing one.  I just want to know how a system-wide keyboard hooking program works.
Thanks 
