Share via


where do I find the definition of the getch function return codes

Question

Tuesday, April 29, 2008 11:18 PM

 

All replies (7)

Tuesday, April 29, 2008 11:43 PM ✅Answered

 

It doesn't return a "code", it returns the character read from the console

(keyboard).

 

- Wayne

 

 


Wednesday, April 30, 2008 12:59 AM ✅Answered

 

Quote>What I was looking for was a complete list of the key codes returned

 

You should learn how to search MSDN for some of this info.
It would be faster than waiting for someone to reply.

 

ASCII Codes
http://www.cplusplus.com/doc/ascii.html

 

ASCII Character Codes
http://msdn.microsoft.com/en-us/library/aa273481(VS.60).aspx

 

Key Scan Codes
http://msdn.microsoft.com/en-us/library/aa299374(VS.60).aspx

 

About Keyboard Input
http://msdn.microsoft.com/en-us/library/ms646267.aspx

 

- Wayne


Tuesday, April 29, 2008 11:51 PM

Hi Wayne,

 

What I was looking for was a complete list of the key codes returned including the extended two

byte codes.  Like 00,59 - 00,68 for F1-F10 and so on.  Is it documented anywhere? 

 


Wednesday, April 30, 2008 8:56 AM

Have  alook in MSDN for Virtual Key code.

Thanx


Thursday, May 1, 2008 6:15 PM

Wayne,

 

Thanks for your reply.  I am porting a DOS application to Windows and I

have found that the getch function returns different character (key codes)

then the old getch.   The keyboard cursor, page, home, end, and other

keys are identified by the new extended key code 0xe0 (use to be 0x00).

The number cursor... key codes use the old extended key code 0x00.

The Alt+key codes are not returned anymore.   The Key Scan Codes

document is close to what I was looking for, but I was hoping that there

was a document that described what was actually returned by getch. 

 

Also, I was trying to determine a simple method to get the missing getch

character key codes that my application used.  Presently, I am substituting

function keys for the Alt+key combinations, but this is not the same.

 

Mike


Thursday, May 1, 2008 7:45 PM

 

Quote> I have found that the getch function returns different character

Quote>(key codes) then the old getch.

 

Some clarification needed. Are you saying that

 

(a) when you run the old DOS version and the new Win32 version

*on the same PC/OS configuration* they show different values from getch?

OR

(b) when you build and run a Win32 version that it shows different values than

the DOS version *did* when run on other (older) systems?

 

What I'm trying to distinguish is whether the difference is due to the getch

implementation or to the platform (hardware and OS) that the two versions

are being run on.

 

Quote>The keyboard cursor, page, home, end, and other keys are

Quote>identified by the new extended key code 0xe0 (use to be 0x00).

 

Again, are you saying that you *see* a difference when the DOS and Win32

versions are run "on the same machine"?

 

Testing for *both* 0x00 and 0xe0 to detect extended keys is nothing new.

I have code such as the following in DOS programs written at least 15 years

ago:

 

Code Snippet

 

key = getch();
  if( key == 0 || key == 0xe0 )
  {
   key = getch();

 

 

 

 

Quote>I am substituting function keys for the Alt+key combinations,

Quote>but this is not the same.

 

Can you use Ctrl+key instead?

 

- Wayne

 


Monday, May 5, 2008 10:18 AM

Hello

 

Re: where do I find the definition of the getch function return codes

 

I am going to mark this thread as answered since you have not followed up with any further information on your problem as requested - I assume you solved the problem yourself or one of the suggestions in this thread helped you solved the problem. If you have a solution you could post it so others can find it. If you don’t have a solution, then please submit further details and then mark the thread as unanswered.

 

Thanks!