如何在 C 中处理 Linux 控制台中按下的键? [英] How to handle key pressed in a Linux console in C?

查看:11
本文介绍了如何在 C 中处理 Linux 控制台中按下的键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Linux 控制台,我想做一个输出随机字符的程序,直到按下 ESC.如何制作这样的键盘处理程序?

I'm using Linux console and I would like to do a program which outputs random characters until ESC is pressed. How can I make such a keyboard handler?

推荐答案

getch() 也许?此外,您需要使用 notimeout() 告诉 getch() 不要等待下一次按键.

getch() from Curses library perhaps? Also, you will need to use notimeout() to tell getch() not to wait for next keypress.

这篇关于如何在 C 中处理 Linux 控制台中按下的键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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