如何处理c ++中的按键事件 [英] How to handle key press events in c++

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

问题描述

我正在编写一个自定义控制台程序。我想让它看起来像一个实际的。所以我想绑定一些动作与按键事件。

I am writing a custom console program. And I want to make it look like an actual one. So I want to bind some actions with keypress events.

例如,当按下向上箭头时,应向用户显示以前执行的命令。我知道SDL。但我认为它不是一个标准的库,是吗?

For example when the up arrow is pressed previously executed commands should be shown to the user. I know about SDL. But I think that it's not a standard library, is it ??

如果有其他替代方法,包括在标准CPP库中,请让我知道。

If there is other alternative of it, that included in standard CPP library, please let me know.

谢谢。

推荐答案

你不会在标准库中找到任何东西。这是所有平台依赖。在Windows中,您具有 GetAsyncKeyState 以获取键盘上键的状态。

You won't find anything in the standard library for that. It's all Platform-dependent. In Windows, you have functions like GetAsyncKeyState to get the state of a key on the keyboard for example.

SDL SFML 都具有与平台无关的事件处理。

SDL and SFML both have platform-independent event handling.

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

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