如何在控制台中获取按键事件 [英] How to get keypress event in console

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

问题描述

我正在学习C,并且在没有按Enter的情况下获取on_key_press_event有问题。
当然我需要字符代码。是否有解决方案?

I'm learning C and have a problem with getting on_key_press_event without pressing Enter. And of course i need character code. Is there solution?

推荐答案

我建议您阅读 here 。我认为

getchar()

可能是你以后的。

编辑:其实可能

#include <conio.h>
_getch()

将为您工作更好,因为它不需要行尾字符(输入按钮)。对于Windows,请参阅以及unix系统似乎包含在诅咒图书馆中。

would work better for you as it does not require the end of line character (enter button to be pressed). For windows refer to this and for unix systems this seems to be included in the curses library.

希望这有帮助!

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

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