What are the differences between the different keypress commands?
key is pressed, keypress, new keypress[edit]
These commands check the state of a keyboard key. They don't wait for anything. "key is pressed" tells you if the key is currently down right. "keypress" tells whether there is a keypress event, which occurs when the player pushes down the button, and also when the key starts to repeat after a delay. "new keypress" is like keypress but without any repeat. Here is a typical example:
if (key is pressed(key:up)) then ( my jump script )
These commands use constants such as use key, cancel key, any key, left key (on either keyboard or joystick), key: left (on the keyboard), key: L, key: esc, etc, which are documented at scancode in the Plotscripting Dictionary and can be found in scancode.hsi.
wait for key and wait for scancode[edit]
("wait for scancode" is identical to "wait for key" but used to act differently.)
The wait for key command waits for the player to press a key. It stops the script until the key is pressed. If the argument is "any key", then it returns the scancode of the pressed key. Writing "wait for key" without any brackets is the same as writing "wait for key (any key)".
The "wait for key" command uses the same constants as "keypress", etc.
Alternatively, you could write you own while loop to wait for a keypress, if you need the waiting to stop under certain conditions. See the Scripts:Skippable wait script. Your while loop must contain a wait(1) command, because key is pressed returns the keyboard state at the beginning of this tick. It does not query the keyboard again.