GRAPHIC WAITKEY$ statement

Purpose | Reads a keyboard character or extended key, waiting until one is ready.
Syntax | GRAPHIC WAITKEY$ [To WaitVar$] GRAPHIC WAITKEY$ ([KeyMask$] [,TimeOut&]) [TO WaitVar$] Function Form: WaitVar$ = GRAPHIC$(WAITKEY$) WaitVar$ = GRAPHIC$(WAITKEY$, [KeyMask$] [,TimeOutVal&])

Remarks

Reads a character or extended key from the keyboard without echoing anything to the screen. If no data is available, GRAPHIC WAITKEY$ will wait for an event to occur. It is very similar to GRAPHIC INKEY$, except that it waits for input to be available. While waiting, time slices are released to the operating system to reduce CPU load.

It returns a string of one or two characters if a key was pressed. If the TO clause is omitted, the keyboard character is discarded.

If the optional KeyMask$ expression is included, only a limited set of keys are recognized. KeyMask$ may include any number of Sub-Masks, one for each key to observe. For example, GRAPHIC WAITKEY$("YyNn") will recognize upper-case or lower-case Y or N (for yes/no answers), while any other key will be ignored. If KeyMask$ is omitted, or evaluates to a zero-length string, any key event will be recognized.

If the optional TimeOutVal& expression is included, it tells the maximum number of milliseconds to wait for a key. GRAPHIC WAITKEY$(5000) will wait a maximum of 5 seconds. The specified TimeOut period will only be approximate, so you should not rely upon precision accuracy. If the TimeOut period is exceeded, a zero-length string is returned. If the TimeOutVal& parameter is omitted, or evaluates to zero (0), it will wait an infinite length of time. The maximum TimeOut& permitted is one hour.

A string length of one ( LEN(i$) = 1) means that a standard character key was pressed. The result string contains the character. An ASC()value between 1 and 31 indicates a control code.

A string length of two (LEN(i$) = 2) means that an extended key was pressed. In this case, the first character in the result string has an ASC() value of zero (0), and the second is the extended keyboard scan code. For example, pressing the F1 key will return CHR$(0, 59).

See also | GRAPHIC INKEY$, GRAPHIC INPUT, GRAPHIC INPUT FLUSH, GRAPHIC INSTAT, GRAPHIC LINE INPUT