Lua Class - input

input is a class in the Teverse Lua API that contains 8 properties, 2 methods and 14 events.

This class cannot be constructed, it is managed by Teverse.

Properties
READONLY
boolean hasScreenKeyboard

True if the device has a screen keyboard

CODE SAMPLE
print(input.hasScreenKeyboard) --> true
READONLY
boolean hasTouchInput

True if the device has touch input

CODE SAMPLE
print(input.hasTouchInput) --> true
READONLY
vector2 mousePosition

Absolute position of cursor in pixels

CODE SAMPLE
print(input.mousePosition) --> vector2(10, 10)
READONLY
number screenPaddingBottom

Padding applied to the bottom of the viewport by Teverse.

CODE SAMPLE
print(input.screenPaddingBottom) --> 1.0
READONLY
number screenPaddingLeft

Padding applied to the left of the viewport by Teverse.

CODE SAMPLE
print(input.screenPaddingLeft) --> 1.0
READONLY
number screenPaddingRight

Padding applied to the right of the viewport by Teverse.

CODE SAMPLE
print(input.screenPaddingRight) --> 1.0
READONLY
number screenPaddingTop

Padding applied to the top of the viewport by Teverse. Mostly on devices with notches.

CODE SAMPLE
print(input.screenPaddingTop) --> 1.0
READONLY
vector2 screenSize

Absolute size of the viewport measured in pixels

CODE SAMPLE
print(input.screenSize) --> vector2(10, 10)
Methods
boolean isKeyDown( keyCode code )

Returns true if the provided key is down

CODE SAMPLE
input:isKeyDown(keyCode) --> true
boolean isMouseButtonDown( number code )

Returns true if the provided button is down, where code is 1, 2 or 3

CODE SAMPLE
input:isMouseButtonDown(1.0) --> true
Events
:on("changed", function( string property, variant oldValue, variant newValue ) end)

Fired when a property is changed.

CODE SAMPLE
input:on("changed", function(property, oldValue, newValue)
  print(property) --> ""  print(oldValue) --> variant  print(newValue) --> variant
end)
:on("fingerDown", function( ) end)

finger down

CODE SAMPLE
input:on("fingerDown", function()

end)
:on("fingerUp", function( ) end)

finger up

CODE SAMPLE
input:on("fingerUp", function()

end)
:on("keyDown", function( enums.keysym keyCode ) end)

Key pressed

CODE SAMPLE
input:on("keyDown", function(keyCode)
  print(keyCode) --> enums.keysym
end)
:on("keyUp", function( enums.keysym keyCode ) end)

Key released

CODE SAMPLE
input:on("keyUp", function(keyCode)
  print(keyCode) --> enums.keysym
end)
:on("mouseLeftDown", function( ) end)

Left mouse button down

CODE SAMPLE
input:on("mouseLeftDown", function()

end)
:on("mouseLeftUp", function( ) end)

Left mouse button up

CODE SAMPLE
input:on("mouseLeftUp", function()

end)
:on("mouseMiddleDown", function( ) end)

Middle mouse button down

CODE SAMPLE
input:on("mouseMiddleDown", function()

end)
:on("mouseMiddleUp", function( ) end)

Middle mouse button up

CODE SAMPLE
input:on("mouseMiddleUp", function()

end)
:on("mouseMoved", function( ) end)

Mouse moved

CODE SAMPLE
input:on("mouseMoved", function()

end)
:on("mouseRightDown", function( ) end)

Right mouse button down

CODE SAMPLE
input:on("mouseRightDown", function()

end)
:on("mouseRightUp", function( ) end)

Right mouse button up

CODE SAMPLE
input:on("mouseRightUp", function()

end)
:on("mouseWheel", function( ) end)

Mouse wheeled

CODE SAMPLE
input:on("mouseWheel", function()

end)
:on("screenResized", function( ) end)

Triggered when the viewport size is changed

CODE SAMPLE
input:on("screenResized", function()

end)

Some sections of our docs are maintained on github.