WaitKey

( PlayBasic 1.61+ )

WaitKey - wait for the player to press a key

Syntax

WaitKey

Description

WaitKey waits for player to press a key. This can be any key. After the player has pressed a key, the game is resumed. WaitKey determines if the player has pressed a key by checking the keyboard buffer. If you want to use WaitKey after accepting keyboard input or twice in a row, you will need to use FlushKeys to clear the keyboard buffer.

WaitKey is often used in simple examples to give the user time to read any text displayed, usually with Print.

Examples

Example of Use

WaitKey waits for the player to press a key. In the below code example, the game will end immediately after the player presses a key.

Print "Press Any Key to End"
Sync
WaitKey
End

Flushing the Keyboard Buffer

If you want to use WaitKey twice or after accepting other keyboard input, you will have to clear the keyboard buffer with FlushKeys.

Print "Press Any Key"
Sync
WaitKey

Print "Press Any Key to End"
Sync
FlushKeys
WaitKey
End

Related Pages

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution 2.5 License.