Share via


_InKey( ) API Library Routine

Returns the first key typed during the timeout period.

int _InKey(int timeout, int flag)
int timeout;                  /* Timeout period. */
int flag;                     /* Option(s). */

Remarks

The timeout period is specified as a number of operating system timer ticks (1000/second). A timeout period of 0 causes Visual FoxPro to wait until the user presses a key. A negative timeout value causes _InKey( ) to return to the calling program immediately if the user doesn't press a key.

You can specify flag as one or both of the following options:

  • SHOWCURSOR or HIDECURSOR

  • MOUSEACTIVE

Use SHOWCURSOR to force the cursor to appear**,** or HIDECURSOR to force the cursor to disappear. If neither is specified, the cursor respects the SYS(2002) setting. The additional flag value MOUSEACTIVE causes _InKey( ) to treat mouse clicks as keystrokes. _InKey returns 151 for a mouse click. To specify two flag values, use the C | or + operator.

Note

Idle routines must not call _InKey().

You can write event handlers that call _InKey( ), but you must be careful because _InKey( ) calls the event handler recursively.

For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.

Example

The following example calls _InKey( ) from Visual FoxPro with two flags.

Visual FoxPro Code

SET LIBRARY TO INKEY
#define SHOWCURSOR   1
#define HIDECURSOR   2
#define MOUSEACTIVE 4
= XINKEY(0, SHOWCURSOR + MOUSEACTIVE)

C Code

#include <pro_ext.h>

FAR Example(ParamBlk FAR *parm)
{
   _RetInt(_InKey((int) parm->p[0].val.ev_long,
      (int) parm->p[1].val.ev_long), 10);
}

FoxInfo myFoxInfo[] = {
   {"XINKEY", (FPFI) Example, 2, "I,I"},
};
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo
};

See Also

Concepts

API Library Routines A-Z

Reference

INKEY( ) Function

ReadTimeout Property

Other Resources

Accessing the Visual FoxPro API

API Library Routines by Category