Skip to main content

Touch

The standard input device for phones, tablets and other touch devices.

Listening For Touch Events

caution

The touchId identifier is only guaranteed to be unique for the specific touch press until _touchreleased is triggered with that identifier, at which point it may be reused for new touch presses.

info

Most touch screens aren't pressure sensitive, in which case the pressure will be 1.

_touchpressed

Triggered when the touchscreen is touched.

function _touchpressed(touchId, x, y, deltaX, deltaY, pressure)
--Logic executed when the event is triggered
end
ParameterTypeNote
touchIduserdata
xnumber
ynumber
deltaXnumberalways 0.
deltaYnumberalways 0.
pressurenumberthe amount of pressure being applied.

_touchmoved

Triggered when a touch press moves inside the touchscreen.

function _touchmoved(touchId, x, y, deltaX, deltaY, pressure)
--Logic executed when the event is triggered
end
ParameterTypeNote
touchIduserdata
xnumber
ynumber
deltaXnumbersince last _touchmoved call.
deltaYnumbersince last _touchmoved call.
pressurenumberthe amount of pressure being applied.

_touchreleased

Triggered when the touchscreen stops being touched.

function _touchreleased(touchId, x, y, deltaX, deltaY, pressure)
--Logic executed when the event is triggered
end
ParameterTypeNote
touchIduserdata
xnumber
ynumber
deltaXnumbersince last _touchmoved call.
deltaYnumbersince last _touchmoved call.
pressurenumberthe amount of pressure being applied.