如何阅读或捕获按Ctrl +一些关键或Alt +一些C键?

编程入门 行业动态 更新时间:2024-10-28 05:14:18
本文介绍了如何阅读或捕获按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键?

本文发布于:2023-11-04 21:47:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559096.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:关键   Ctrl   Alt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!