<< Click to Display Table of Contents >> Navigation: ThinBASIC Modules > UI (User Interface) > Keyboard > GetAsyncKeyState |
Description
Determines whether a key is down at the time the function is called.
Syntax
n = GetAsyncKeyState(vKey)
Returns
Number, non-zero if key is pressed.
Parameters
Name |
Type |
Optional |
Meaning |
vKey |
Number |
No |
Specifies one of 256 possible virtual-key codes. For more information, see Virtual-Key Codes |
Remarks
Use GetAsyncKeyState with vKey equal to -1 to reset keys flags
Restrictions
See also
Examples
uses "console", "ui"
' Prepare for reading key states
GetAsyncKeyState(-1)
Long pressed = false
do
' Check if Q is pressed
pressed = GetAsyncKeyState(%VK_Q)
if pressed then exit do
printl "Not pressed, keep trying to press Q..."
loop
printl "YES! Key was pressed!" in 14
sleep 1000
waitkey