Getche - 输入密钥 [英] Getche - Enter key

查看:98
本文介绍了Getche - 输入密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道以下说明:


char c;

c = getche();


...读一个角色。如果我输入''g'',那么c ==''g''。但是,如果我按下箭头,Enter键,Del键等,那么同样如此...?

I know that the following instructions:

char c;
c=getche();

...read a character. If I type, for example, ''g'', then c==''g''. But what is equally c with if I press an arrow, the Enter key, the Del key etc.?

推荐答案

在ASCII表中查找这些键的值。


或者,将c赋值给int并显示int。
Look in the ASCII table for the values of these keys.

Or, assign c to an int and display the int.



查看这些键的值的ASCII表。

或者,将c赋给int并显示int。
Look in the ASCII table for the values of these keys.
Or, assign c to an int and display the int.



最好通过打印各种按键的c值来自行调查。那是因为:

1. ASCII编码可能无处不在,但是没有法律(或标准)要求你的系统使用ASCII。

2.一些键表示为转义序列,其中单个按键生成字符流。要检测到这一点,你想在getche上连续循环,打印出你得到的十六进制文本。

Better to investigate this yourself by printing out the value of c for various keypresses. That''s because:
1. ASCII encoding may be ubiquitous, but there is no law (or Standard) that requires your system to use ASCII.
2. Some keys are expressed as escape sequences, where a single keypress generates a stream of characters. To detect this, you want to loop continuously on getche, printing out whatever you get as hexadecimal text.



1. ASCII编码可能是无处不在,但没有法律(或标准)要求你的系统使用ASCII。

2.某些键表示为转义序列,其中一个按键生成一个字符流。要检测到这种情况,您需要在getche上连续循环,以十六进制文本的形式打印出任何内容。
1. ASCII encoding may be ubiquitous, but there is no law (or Standard) that requires your system to use ASCII.
2. Some keys are expressed as escape sequences, where a single keypress generates a stream of characters. To detect this, you want to loop continuously on getche, printing out whatever you get as hexadecimal text.



是的,标准不要求ASCII,但我还没有看到在Unix / Linux或Windows上运行的C版本没有使用它。并不是说在某个地方有一个5位字符没有C潜伏。


一个按键生成一个字符流的例子是什么?而且我并不是靠靠钥匙说自动重复。 Autorepeat只是一个快速打字员。

Yes, ASCII is not required by the standard but I have yet to see a version of C running on Unix/Linux or Windows that doesn''t use it. Not to say there isn''t a C lurking somewhere with a 5-bit char.

What is an example of one keypress generating a stream of characters? And I don''t mean autorepeat by leaning on the key. Autorepeat is just a fast typist.


这篇关于Getche - 输入密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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