How to detect key presses?

I am making a stopwatch type program in Python and I would like to know how to detect if a key is pressed (such as p for pause and s for stop), and I would not like it to be something like raw_input, which waits for the user’s input before continuing execution.

Anyone know how to do this in a while loop?

I would like to make this cross-platform but, if that is not possible, then my main development target is Linux.

Leave a Comment