How to decide which window the event in CGEvent​Tap​Call​Back goes to?

I'm trying to use CGEventTapCreate to create a event tap for kCGEventKeyDown. Inside the CGEventTapCallBack function, how should I figure out which window the event goes to?

How to decide which window the event in CGEvent​Tap​Call​Back goes to?
 
 
Q