BUG: getch() Returns Incorrect Extended Key CodesLast reviewed: July 24, 1997Article ID: Q107427 |
The information in this article applies to:
SYMPTOMSThe getch() run-time library function fails to return the correct extended character code for certain key sequences. There are two known situations in which incorrect codes are generated:
STATUSMicrosoft has confirmed this to be a bug in the products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONIn the sample code below, the ALT key combined with any ASCII character returns the ASCII character code instead of the extended character code. The RIGHT CTRL key combined with any of the function or editing keys also fails with Visual C++ 1.0, returning the code for the function or editing key alone. The LEFT CTRL key combined with a function key or editing key returns the correct code. The set of affected editing keys are: END, PAGE UP, PAGE DOWN, HOME, RIGHT ARROW, and LEFT ARROW. The table below demonstrates some of the actual versus expected values that result when the sample below is run with the input shown:
Input Expected Actual
ALT+C 0 - 2eH 63H (C) RT CTRL+F4 0 - 61H 0 - 3eH (F4) RT CTRL+PAGE UP 0 - 84H 0 - 49H (PAGEUP) RT CTRL+END 0 - 75H 0 - 4fH (END) Sample Code
/* Compile options needed: none */ void main(void) { int testChar; do { testChar = getch(); printf("%x - ", testChar); testChar = getch(); printf("%x \n", testChar); } while (testChar != 0x001B); /* Repeat until ESC key*/ } |
Keywords : CRTIss vcbuglist400 vcbuglist500
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |