Skip to content
Download

Input

An action is a name bound to keys and gamepad buttons, defined in Project settings.

Function What it does
held(action) The action is held.
pressed(action) The action was pressed on this step.
released(action) The action was released on this step.
axis(negative, positive) From -1 to 1: the positive action minus the negative. The stick has a 0.25 dead zone.
self.hspeed = axis("esquerda", "direita") * 2
if pressed("pular") then self.vspeed = -4 end

held, pressed and released also accept a key.

if pressed(Key.Escape) then quit() end
Group Keys
Letters A … Z
Numbers Num0 … Num9
Arrows Left, Right, Up, Down
Special Space, Enter, Escape, Tab, Backspace
Modifiers LShift, RShift, LCtrl, RCtrl
Function F1 … F12
Function What it does
mouseX(), mouseY() Mouse position in the world (accounts for the camera).
mouseGuiX(), mouseGuiY() Mouse position on screen, for onRenderGui.
mouseHeld(button) The button is held.
mousePressed(button) The button was pressed on this step.
mouseReleased(button) The button was released on this step.
mouseWheel() How much the wheel turned on this step: positive is up.
if mousePressed(Mouse.Left) then
self:setDirection(self:angleTo(mouseX(), mouseY()))
end

Buttons: Left, Middle, Right. In C++, mouseGuiX, mouseGuiY and mouseWheel are under Input::.

The gamepad is read through actions. The first connected gamepad is used. Names used in Project settings:

Group Names
Buttons Pad:A, Pad:B, Pad:X, Pad:Y, Pad:Start, Pad:Back, Pad:LB, Pad:RB
D-pad Pad:Up, Pad:Down, Pad:Left, Pad:Right
Left stick Pad:LeftX-, Pad:LeftX+, Pad:LeftY-, Pad:LeftY+