Keys To The Kingdom
Tim Daneliuk
tundra at tundraware.com
Sun Jul 8 20:30:01 EDT 2001
Tim Daneliuk wrote:
>
> I have a two part question about accepting keyboard input in python:
>
> Is there a standard way to read one keystroke at a time rather than
> doing line input via raw_input()?
To calrify - I know this is possible using features of the msvcrt module,
but I really want something that is portable across all python environments.
If that's not possible, is there an equivalent unix/MacOS feature so I can
at least select which one to use at runtime based on the OS discovered
at startup? TIA...
>
> For some reason, I cannot seem to catch Ctrl-C when it is typed in response
> to a raw_input() call. This code still blows out of the python interpreter
> when the user keys in Ctrl-C:
>
> try:
> x=raw_input()
> except KeyBoardInterrupt:
> # Handle the Ctrl-C and regroup
> ...
>
> ------------------------------------------------------------------------------
> Tim Daneliuk
> tundra at tundraware.com
--
------------------------------------------------------------------------------
Tim Daneliuk
tundra at tundraware.com
More information about the Python-list
mailing list