Normally you'd use an API that records keypresses as keypress events in a queue which you can later clear. If you want to react to these events while you're literally doing something else, you'll have to use threads.
Actually, before doing that you'll really want to look into events. I'm not sure what exactly you're trying to do, but you probably don't need threads for it.