Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
#include <conio.h>
#include <iostream.h>

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


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
Posted
Updated 24-Apr-10 4:18am
v2

See if this [^] helps.
:)
 
Share this answer
 
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).
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900