For attaching to another process you should read on this windows API:
ReadProcessMemory, WriteProcessMemory(This functions are detectable by the AV, so instead use VirtualProtect + memcpy, memset)
Now for For Injecting a DLL:
To make a program that it is not seen you should learn to hook NtQuerySystemInformation, to remove your program from process list.
If hooking NtQuerySystemInformation is too hard you could always just make your application invisible or don't create a window,this way you will only be visible into the system processes.
To read keyboard keys there are some windows API like GetAsyncKeyState().