F1和其他功能键ASCII代码在C ++中 [英] F1 and other function keys ASCII codes in c++

查看:312
本文介绍了F1和其他功能键ASCII代码在C ++中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <conio.h>
#include <iostream.h>

void main()
{
    cout<<"press ESC to exit ":
    while(getch()!=27);
}



当我们按ESC时该程序将结束,因为ESC = 27
但是现在我想制作一个程序i,当用户按F1程序时显示帮助
或其他适用于我想要的值,ASCII码或F1键和所有功能的任何内容
keys.Please指导我这件事.
谢谢
bye



this program will end when we press ESC because ESC = 27
but now i want to make a program i which when user press F1 program show help
or other working for i want value, ASCII code ,or any thing about F1 key and all function
keys.please guide me in this matter.
thanks
bye

推荐答案

查看此[ ^ ]帮助.
:)
See if this [^] helps.
:)


不要将键名与字符名混淆:不是所有字符都由键生成,也不是所有键都产生字符.

功能键(如箭头等)不会生成字符.因此,必须使用较低级别的功能(例如win32键盘API)读取它们

但是,在控制台模式下,它们可能会生成字符序列(通常为"\ 0",后跟代码).

您可以使用循环来检查它-在用getch获得字符后,将其打印为数字.

如果您按"A",您将得到65,如果按F1,您可能将得到
0,并且getch将再次从键盘驱动程序缓冲区中再获取一个字符(没有任何新的压力),即功能代码字符(注意:它可能与另一个常规字符相同,因此您不能简单地丢弃0:它具有语义上的含义.)
Don''t confuse the name of the key with the name of a character: not all characters are generated by a key, and not all keys generate charaters.

Function keys, like arrows etc. don''t generate characters. Hence they must be read with lower level functions (like the win32 Keyboard API)

In console mode -howerver- they may generate character sequences (typically a ''\0'' followed by a code).

You can check it with a loop that -after getting a char with getch- prints it as a number.

if you press "A" you will get 65, if you press F1 you will probably get
0, and getch will succeed again taking one more character form the keyboard driver buffer, (without any new pressure) that is the functional code character (note: it may be the same of another regular character, so you cannot simply discard the 0: it has a semantic meaning).


您已经问了两次,并回答了两次.请不要再问了.将来,如果您不明白答案,请编辑您的帖子以解释为什么不明白答案.如果仍然不了解,请考虑答案不会改变,这是您需要改变的技能和理解水平.
You''ve asked this twice and been answered twice. Please don''t ask it again. In future, if you don''t understand an answer, edit your post to explain why you don''t get it. IF you still don''t get it, consider that the answer will not change and it''s your level of skill and understanding that needs to change.


这篇关于F1和其他功能键ASCII代码在C ++中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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