A few days ago, a user asked if it's possible to capture keys pressed in the active window. After he got the answer, strangely enough he/she deleted the thread. I believe knowledge should be free and available to everyone, especially in this open source community. So if anybody is still interested in how to capture pressed keys, check the attachment. It's a low level keyboard hook, for more technical details, please read this msdn entry:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms644990%28v=vs.85%29.aspx