在python中处理键盘事件 [英] Handling keyboard events in python

查看:312
本文介绍了在python中处理键盘事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何处理python中的键盘事件?更确切地说,我需要为我的命令行应用程序管理键盘箭头和其他一些键. 是否有用于此的模块,或者我需要使用例如如果get(key)==(mykey):做某事"(它是伪代码)来逐个密钥处理? 我使用的是Gnu/Linux操作系统.

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 need to handle key by key using for example "if get(key)==(mykey): do something" (it's pseudo-code)? I'm on Gnu/Linux OS.

推荐答案

您可能正在寻找python

You're probably looking for a python (n)curses library. This will allow to "get around" your terminal buffering and work with key-presses directly.

这篇关于在python中处理键盘事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆