Name
IsKeyDown -- check if a key is pressed (V1.5)
Synopsis
state = IsKeyDown(key$[, rawkey])
Function
This function checks if the key specified by key$ is currently pressed. If it is, this function will return True otherwise it will return False.

key$ is a string representing a key on your keyboard. This can be one of the following control keys:

UP
Cursor up
DOWN
Cursor down
RIGHT
Cursor right
LEFT
Cursor left
HELP
Help key
DEL
Delete key
BACKSPACE
Backspace key
TAB
Tab key
RETURN
Return key
ENTER
Enter key
ESC
Escape
SPACE
Space key
F1 - F16
Function keys
INSERT
Insert key
HOME
Home key
END
End key
PAGEUP
Page up key
PAGEDOWN
Page down key
PRINT
Print key
PAUSE
Pause key

Alternatively, key$ can also be a character from the English alphabet, e.g. "A", or a string containing a number from 0 to 9. Note that IsKeyDown() doesn't support Unicode keys.

Starting with Hollywood 4.0, you can check the status of the modifier keys, too. The following modifier keys can be checked using IsKeyDown():

LSHIFT
Left shift key
RSHIFT
Right shift key
LALT
Left alt key
RALT
Right alt key
LCOMMAND
Left command key
RCOMMAND
Right command key
LCONTROL
Left control key
RCONTROL
Right control key

Starting with Hollywood 6.1 you can pass the special string ANY in key$ to check for an arbitrary key to be pressed.

Starting with Hollywood 7.1 there is an optional argument rawkey. If this argument is set to True, IsKeyDown() will treat key$ as a raw key and check if it is down. In that case, key$ must be one of the raw keys defined by Hollywood. See Raw keys for details. The difference between normal keys and raw keys is described in the documentation of the OnRawKeyDown event handler. See InstallEventHandler for details.

Inputs
key$
key to check
rawkey
optional: True if key$ is a raw key (defaults to False) (V7.1)
Results
state
True if key$ is pressed, False otherwise
Example
Print("Press F1 please.")
Repeat
  VWait
Until IsKeyDown("F1") = True
The above code waits until the F1 key is pressed. (you can have that easier by using WaitKeyDown(); the one above is only useful if you want to do something while the key is not pressed)

Show TOC