What are the differences between the "wait for key" command and the "key is pressed" command?
[edit] key is pressed
The key is pressed command works for any key on the keyboard, and will tell you if the key is being pressed right at the instant the command is run. It does not wait, it just tells you what the key is doing right now. Here is a typical example of its use:
if (key is pressed(key:up)) then, begin my jump script end
If you need to wait for a certain key to be pressed, you can use the wait for scancode command. It uses the same key constants as key is pressed.
The command 'key is pressed' uses the constants 'key: left', 'key: L', 'key: esc', etc, which may be found in scancode.hsi. Scancode.hsi must be included for you to use these constants.
[edit] wait for key
The "wait for key" command waits for the player to press a key. It stops the script until the key is pressed. No value is returned.
The "wait for key" command use the following constants: upkey, downkey, leftkey, rightkey, usekey, cancelkey, menukey, anykey.
Please note that:
- The two sets of constants are not interchangable. You can't use "upkey" instead of "key:up" with the "wait for key" command.
- "use key" means SPACE or ENTER or CTRL or joystick button 1, "cancel key" means ALT or ESC or joystick button 2, "menu key" is the same as "cancel key".
- Key:numlock refers to the num lock key and pause/break key.
- Writing "wait for key" without any brackets is the same as writting "wait for key (any key)" (The argument defaults to anykey)