know what key is pressed

You can do some of that. See this thread.