If the process of your application is
different from the process of target window,
then you need to set a systemwide hook
for keyboard messages.

The hook function is called before a keyboard
message is sent to target application.
You can modify the message in the hook
procedure if the message is meant to the
application that you are looking for.

Then the modified message goes to the
appropriate application.

I dont remember the exact syntax offhand,but
you need to do something like this :

1. Write a keyboard hook function
Refer Win32 API documentation for the
exact function signature.
Systemwide hook procedure must
reside in a DLL.

2. Set the systemwide hook by calling
SetWindowsHookEx() call.
Use KEYBOARD hook.

Let me know if it works for you.

shridhar.