Waits for a specific key to be pressed.
WaitForKey (key1, key2, key3, key4, key5)
(s) key1 - key5 five keystrokes to wait for.
(i) position of the selected keystroke (1-5).
WaitForKey requires five parameters, each of which represents a keystroke. The WIL program will be suspended until one of the specified keys are pressed, at which time the WaitForKey function will return a number from 1 to 5, indicating the position of the "key" that was selected, and the program will continue. You can specify a null string ("") for one or more of the "key" parameters if you don't need to use all five.
WaitForKey will detect its keystrokes in most, but not all, Windows applications. Any keystroke that is pressed is also passed on to the underlying application.
Note: Certain keys, such as {ALT} and {F10} may not work with this function and should be avoided.
WaitForKey supports the following keycodes:
{BACKSPACE}
{BS}
{CLEAR}
{DELETE}
{DEL}
{DOWN}
{END}
{ENTER}
{ESCAPE}
{ESC}
{F1}
{F2}
{F3}
{F4}
{F5}
{F6}
{F7}
{F8}
{F9}
{F10}
{F11}
{F12}
{F13}
{F14}
{F15}
{F16}
{HELP}
{HOME}
{INSERT}
{INS}
{LEFT}
{NUMPAD*}
{NUMPAD+}
{NUMPAD-}
{NUMPAD.}
{NUMPAD/}
{NUMPAD0}
{NUMPAD1}
{NUMPAD2}
{NUMPAD3}
{NUMPAD4}
{NUMPAD5}
{NUMPAD6}
{NUMPAD7}
{NUMPAD8}
{NUMPAD9}
{PGDN}
{PGUP}
{PRTSC}
{RIGHT}
{SPACE}
{SP}
{TAB}
{UP}
To enter an Alt, Control, or Shift key combination, precede the desired character with one or more of the following symbols:
Key |
SendKey equivalent |
Alt |
! |
Control |
^ |
Shift |
+ |
Notes:
NumLock must be on for the codes {NUMPAD0} through {NUMPAD9} to be generated.
Also, the function cannot distinguish between the two "Enter" keys on the keyboard (both will generate an {Enter} code)
Certain special keycodes, such as {ALT} and {F10} may not work with this function and should be avoided.
IntControl (80,0,0,0,0) can be used to wait for user to release *all* keys before proceeding.
k = WaitForKey("{F11}", "{F12}", "{INSERT}", "", "") Switch k Case 1 Message("WaitForKey", "You pressed the F11 key") Break Case 2 Message("WaitForKey", "You pressed the F12 key") Break Case 3 Message("WaitForKey", "You pressed the Insert key") Break EndSwitch