waitkey( )

Blitz3D Forums/Blitz3D Beginners Area/waitkey( )

I looked at the GetKey() help and found the following code. GetKey() checks if the user presses a key and returns the ASCII value. This is printed to the screen. Then I added a line which converts the ASCII code to the corresponding character, using the Chr() function, and prints that to the screen as well.

; GetKey Example

Print "Please press any ASCII key..."

While Not value
   value = GetKey()
Wend 

Print "You pressed key with an ASCII value of:" + value

Print "This corresponds to the following character: " + Chr(value)

WaitKey


Instead of the While...Wend loop with GetKey() you could also use a single call to WaitKey() I guess, as that command will wait until a key is pressed. It also returns the ASCII code.

Print "Please press any ASCII key..."

value = WaitKey()

Print "You pressed key with an ASCII value of:" + value

Print "This corresponds to the following character: " + Chr(value)

WaitKey