PRB: INKEY() May Return Same ASCII Values for Different KeysID: Q138558 The information in this article applies to:
SYMPTOMSUsing INKEY() to trap for a keystroke can sometimes lead to unexpected results. For example, INKEY() will return the same value, 19, for the LEFT ARROW key and ALT+R. This effect may be altered by using the following command before using the INKEY():
RESOLUTIONUse the SET COMPATIBLE DB4 command immediately before you use the INKEY() function. Then use the SET COMPATIBLE OFF command after using INKEY(). This may have side effects. Please see SET COMPATIBLE DB4 in the Help file.
STATUSThis behavior is by design.
MORE INFORMATIONCertain commands and functions in FoxPro, including INKEY(), behave differently depending on the SET COMPATIBLE setting. For more information, please see the following article in the Microsoft Knowledge Base:
Step-by-Step ResolutionUsing INKEY(0,'M') to trap for a key or mouse click, you can distinguish which key was pressed by using the following loop example. 1. Place the following code into a program (.prg) file, and then run it.
2. Try pressing ALT+R and the LEFT ARROW key. Each will return an ASCII
3. Press the ESC key. The window will come back up with SET COMPATIBLE DB4.
4. Try pressing ALT+R, and the LEFT ARROW key again. ALT+R returns -418 and You can use this technique to maintain a distinction between hot keys and
other keystrokes.
Additional reference words: 3.00 VFoxWin KBCategory: kbprg kbcode kbprb KBSubcategory: FxprgGeneral |
Last Reviewed: October 25, 1995 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |