Keyboard input buffer

How do I clear it? For Windows. I want to grab every character
pressed before it goes to Windows and the active application.
Any help with the question and how to ADD characters to the
keyboard buffer before handing to Windows.  TIA