如何阅读或捕获按Ctrl +一些关键或Alt +一些C键? [英] How to read or capture Ctrl+some key or Alt+some key in C?

查看:200
本文介绍了如何阅读或捕获按Ctrl +一些关键或Alt +一些C键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如我想要做一些事情时的<大骨节病>控制与任何其他关键关键是$ P $某种组合pssed(也可能是<大骨节病>替代键)。然后从标准输入如何阅读在C程序组合键​​为输入。

我用简单的的getchar()试过才知道这些组合的ASCII值。但它是一些1至25和其他一些值,一些组合键。有没有什么标准库函数读取它们。不要问我为什么要这么做。

修改:我的平台是Turbo C的在Windows

For example I want to do some thing when some combination of Ctrl key with any other key is pressed (or it may be Alt key).Then from the standard input how to read that key combination in C program as an input.

I tried with simple getchar() to know the ASCII values of these combinations. But it was some 1 to 25 and some other values for some key combinations. Is there any standard library function to read them. Dont ask me why do you want to do that.

Edit: My platform is Turbo C on Windows.

推荐答案

简短的回答:在特定于平台的方式

The short answer: In a platform specific way.

长的答案:C的输入/输出的概念是流标准输出和标准输入。您在上面简单地提到的getchar()函数从标准输入流中读取。 C没有键盘的任何想法,尽管键盘是一种常见的输入法。通常有你的键盘和什么获取通过传递给标准输入你的C程序之间的抽象几层。要做到这一点的机制是定义的实施,而不是C的一部分的。你提到ASCII,但C不会尽管它是非常普遍的要求ASCII。

The long answer: C's Input/Output concept is that of the streams standard output and standard input. The getchar() function that you mentioned above simply reads from the standard input stream. C doesn't have any notion of keyboards, despite keyboards being a common input method. There are normally several layers of abstraction between your keyboard and what gets passed through to standard input in your C program. The mechanism to do this is implementation defined, and not part of C at all. You mentioned ASCII, but C doesn't require ASCII despite it being extremely common.

一些库试图提供便携式键盘输入设备,如 SDL 并的诅咒

Some libraries attempt to provide portable keyboard input facilities, such as SDL and curses.

又见 comp.lang.c常见问题解答对系统的依赖性,尤其是19.5。

See also the comp.lang.c FAQ on system dependencies, particularly 19.5.

这篇关于如何阅读或捕获按Ctrl +一些关键或Alt +一些C键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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