ChrSaw(), InKey(), LastKey()
These functions are all concerned with the keyboard buffer. CHRSAW() and INKEY() let you check if there's anything there, while LASTKEY() tells you what used to be there.
Usage |
lKeyPressed = CHRSAW( [ nSeconds ] ) nKeyValue = INKEY( [ nSeconds ] [ , ] [ cFlags ] ) |
Parameter |
Value |
Meaning |
nSeconds |
Numeric |
How long should we wait for a keystroke or click? |
cFlags |
"M" |
Pay attention to the left mouse button, too. |
"E" |
Expand keyboard macro and return a keystroke from it. |
|
"H" |
Hide the cursor while we wait. |
|
"S" |
Show the cursor while we wait. |
|
lKeyPressed |
.T. |
There's something in the keyboard buffer. |
.F. |
There's nothing in the keyboard buffer. |
|
nKeyValue |
0 |
There's nothing in the keyboard buffer. |
151 |
The user clicked the left mouse button. |
|
Other numbers |
The code for the key pressed by the user. See Help. |
Example |
IF NOT CHRSAW(5) && wait 5 seconds WAIT WINDOW "C'mon, buddy, DO something!" ENDIF |
Usage |
nCode = LASTKEY() |
Example |
* This is the beginning of a Valid method. It lets you bail * out when the user chooses the Cancel button. * We'll also stuff the keyboard with something innocuous so * we don't trigger canceling of another Valid by accident. IF LASTKEY()=27 KEYBOARD CHR(255) =INKEY() && eat the character we just keyboarded RETURN .T. ENDIF * now perform the actual validation |
See Also |
Cancel Property, Click, DblClick, KeyPreview, KeyPress, Set TypeAhead |