I don't have time to write the code, but I think this is do-able. Although morally I think this is wrong.
Do a search for onkeypress or onkeydown. If you can't spend the time to write code, then check out irt.org for some coding examples in their JavaScript FAQs.
That solves the problem of getting the key pressed. Sending the data over to your server is another problem.
On approach would be to put in a hidden image. Say 1x1 pixel transparent gif as the default. Put it anywhere on the site. You know how image roll overs work? If not, look it up. Notice the code for the rollover involves replacing the src= with a URL to another image? Replace that with your PHP script and pass the key press(es). Notice that when you do this, this all takes place in the background of the borwser. Meaning the user doesn't have to hit submit on anything. Its slick, but you may actually kill your PHP script if you have a lot of people hitting your page and typing a lot of stuff in.