These keys do not have "ASCII" code. The ASCII table consists of 128 characters, send 32 control and 96 printable - and the control ones contain only "digitable" keys - type "enter", "tab" - and some others for which the current PC keyboards do not have "beep" keys, "form feed", etc...
Well, only the current keyboard has 104 keys - mostly modifiable with shift and/or alt - and the shift and alt themselves have no match in this table.
What happens is that the keyboard sends a hardware code to each keystroke, and the operating system translates and makes these signals available to programs - but this is done in different layers, and what code you get for which key depends a lot on which call to the system you’re making.
The operating system method you are using is used by the C library function you use to read the keyboard- as you did not put which is the effective call to get the key code, it is not possible to expand this answer with a survey about what codes would be available to you.
The tip is to realemten print the incoming code -and that, some read functions, for those keys that do not have a direct ASCII code, the S.O. provides a multi-byte code, and returns one byte at a time to your program.
Print the code on the screen is the best solution for you to try to isolate them:
static void keyEvent( unsigned char key, int x, int y) {
printf("Code: %02x\n", key);
}
Now, pay attention to another tip: It is useless to invest a lot of time in a super-interface for your program if it will only work in Windows CMD: most of these functions depend not only on the operating system and some will depend on the type of terminal.
If the program is realemten useful for renting thing: (1) power users are accustomed to terminal programs that work only "top to bottom"- preferably consuming command linah parameters, and with one or another occasional data entry; Users "no power" expect a graphical interface anyway.
Alias, if you want to have a legal interface,the tip is to make the program in another language - like Python, Java , Ruby and choose a library for graphical interfaces (or even make your program be web-based). Even if your program has parts that are best done in C (for example, a calculation sequence where it is better to have all the processor control), you can call isolated functions of C from the program done in these other languages.
I was going to say p/ you printar and see what the screens are but you said you couldn’t, what happened?
– PauloHDSousa
http://stackoverflow.com/a/2877857/6101515
– JuniorNunes
@Paulohdsousa gave error and simply closed the Prog, perhaps because of the variable type, I tried printf(key); inside the keyEvento, before the first if.
– Mathiasfc
You may find on the net the ASCII value p/ these keys but it is not reliable, the best is you pick up yourself, these values change depending on the OS.
– PauloHDSousa
@Juniornunes worth, I had already seen this post, but anyway, I found nothing here in Sopt regarding this, I saw in this same post that using Opengl and GLUT exists for example GLUT_KEY_UP, maybe that’s the way...
– Mathiasfc