ActionPressed

Family: Studio · One form

What it does

Tells whether an input action has just been pressed. Actions are the named controls defined in the editor, such as jump.

Syntax

ActionPressed(action string) → integer

Parameters

NameTypeMeaning
actionstringThe action's name.

Every form returns

integer

1 on the read where the action goes down, 0 otherwise.

Good to know

  • The press is detected between two reads of the same action, so a do ... Sync() loop sees it once. Two reads in the same frame give the same answer.
  • An action counts as down when its value is above 0.5. Its keys and buttons can be rebound by the player.

Example · generated

DO  Print(ActionPressed("value"))  Sync()LOOP

ActionPressed is called and its answer is printed every frame. The DO … LOOP is not decoration: a classic BASIC program ends the moment it runs out of lines, and Sync() is what draws the frame.

133 commands in Studio