Handling keyboard events in python

前端 未结 4 1754
忘掉有多难
忘掉有多难 2021-01-27 23:01

How can I handle keyboard events in python? More exactly I need to manage keyboard arrows and some other keys for my command-line application. Is there a module for this or I ne

4条回答
  •  别那么骄傲
    2021-01-27 23:51

    Would the cmd module suit your needs? It handles command-line history through the arrow keys, for instance, as well as completion.

    If you need to catch a single key, there is a cross-platform recipe for this (see also Python read a single character from the user on StackOverflow).

提交回复
热议问题