What does getch () really get? Scan codes?

#include <conio.h> int main (void) { for (;;) { unsigned char ch = getch(); printf ("0x%02X\n", ch); } } 

I want to get a scan code.

Here is a description from Wikipedia :

  Reads a character directly from the console without buffer, and without echo. 

When I hit Del , it shows 0xE0 0x53.

When I pressed Ctrl + PgUp , it shows 0xE0 0x86.

Although some of them are the same as in the table, most of the values ​​that it shows are different from them.

So, does getch() really get scan codes?

Here is the scan code table (usually used 2)

Scan code

+6
source share
1 answer

I launched the console application in VS 2012 (C ++) and got the same results as you. He said getch () is deprecated and I have to use _getch (), but that didn't make any difference.

Then I found a table that matches it (right column). For me, the “white” keys used shift and the equivalents of a numeric keypad, the “gray” keys were autonomous scrolling up, down pages, etc. One mismatch I found is to enter on the numeric keypad just like a regular input key.

http://www.itlnet.net/programming/program/Reference/msc/ng7d68f.html

I don’t know where this table comes from, except if you click "About the manual", it says: "Microsoft C Database, Copyright (C) 1987, author Peter Norton." Where Peter got it, I don't know.

0
source

All Articles