Console_WaitKey

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Modules > Console >

Console_WaitKey

 

Description

 

Waits until a keys has been pressed (within a timeout) then it returns it.

 

Syntax

 

Console_WaitKey [ (nSecsTimeOut [, TextToPrint] ) ]

 

Or

 

WaitKey [ (nSecsTimeOut [, TextToPrint] ) ]

 

Returns

 

Return a string

Returns the key pressed like encloses into a square brakets.

 

Parameters

 

Name

Type

Optional

Meaning

nSecsTimeOut

Numeric

Yes

Specifies the maximum number of seconds to wait for a key (timeout)

 

If 0 (zero) function will wait indefinitely until a key is pressed

If number of seconds will pass, "[TIMOUT]" string will be returned.
 

TextToPrint

String

Yes

An optional Text to Print on screen.
 
Syntax to use is the same that is available for PrintL function, all the options are available including colors.

This option can avoid to have a PrintL command just before wait in order to give user some information.
 

 

Remarks

 

Specials keys are returned like:

    [F1]

    [F2]

    [F3]

    [F4]

    [F5]

    [F6]

    [F7]

    [F8]

    [F9]

    [F10]

    [F11]

    [F12]

    [UP]

    [DOWN]

    [LEFT]

    [RIGHT]

    [PGUP]

    [PGDOWN]

    [HOME]

    [END]

    [CANC]

    [DELETE]

    [TAB]

    [RETURN]

    [ESC]

    [ALT]

    [CTRL]

    [SHIFT]

 

Or if timeout is expired:

    [TIMEOUT]

 

Restrictions

 

Alias

 

WaitKey

 

See also

 

Console Module, Console_Read, Console_ReadLine

 

Examples

 

...

 

Printl("Key pressed: " + Console_WaitKey(10))

' if the caps lock is enabled and the user press the X key,

' results: Key pressed: [X]

 

...

 

  WaitKey
  WaitKey 0
  WaitKey 0, "Test" In %CCOLOR_BCYAN
  WaitKey (0)
  WaitKey(0, "Press a key to continue")
  WaitKey 0, "Press a key to continue"
  WaitKey "Press a key to continue" In %CCOLOR_FGREEN
  WaitKey 3, "Wait 3 secs or press a key to continue"