input

(module)

Module for accessing input devices such as touches, keyboard, mouse and gamepads

Touches

Gestures

Keyboard

key.pressing(keyCode)

Queries whether the key is currently being pressed this frame

Parameters:

keyCode (constant) – The keyCode to query

Returns:

Is the key being pressed this frame

Return type:

boolean

key.wasPressed(keyCode)

Queries whether the key is was pressed down this frame

Parameters:

keyCode (constant) – The keyCode to query

Returns:

Was the key pressed down this frame

Return type:

boolean

key.wasReleased(keyCode)

Queries whether the supplied key code was released this frame

Parameters:

keyCode (constant) – The keyCode to query

Returns:

Was the key released this frame

Return type:

boolean

key.modifiers()

Queries the current key modifiers as a bit field, which is composed of the following bit mask constants:

Parameters:

keyCode (constant) – The keyCode to query

Returns:

Was the key released this frame

Return type:

boolean

Constants - Key Codes

leftAlt: const
rightAlt: const
alt: const
leftCtrl: const
rightCtrl: const
ctrl: const
leftCmd: const
rightCmd: const
cmd: const
esc: const
return: const
tab: const
space: const
backspace: const
up: const
down: const
left: const
right: const
insert: const
delete: const
home: const
end: const
pageup: const
pagedown: const
print: const
plus: const
minus: const
leftbracket: const
rightbracket: const
semicolon: const
quote: const
comma: const
period: const
slash: const
backslash: const
tilde: const
f1: const
f2: const
f3: const
f4: const
f5: const
f6: const
f7: const
f8: const
f9: const
f10: const
f11: const
f12: const
numpad0: const
numpad1: const
numpad2: const
numpad3: const
numpad4: const
numpad5: const
numpad6: const
numpad7: const
numpad8: const
numpad9: const
num0: const
num1: const
num2: const
num3: const
num4: const
num5: const
num6: const
num7: const
num8: const
num9: const
a: const
b: const
c: const
d: const
e: const
f: const
g: const
h: const
i: const
j: const
k: const
l: const
m: const
n: const
o: const
p: const
q: const
r: const
s: const
t: const
u: const
v: const
w: const
x: const
y: const
z: const

Gamepad

class gamepad
all: table<gamepad>

A list of all currently connected gamepads

current: gamepad

The current main active gamepad (or nil if none connected)

virtual: gamepad.virtualGamepad

Gets or creates a virtual gamepad which will substitute on-screen controls if no controller is currently connected

connected: function(gamepad)

Callback for when a gamepad is connected

disconnected: function(gamepad)

Callback for when a gamepad is disconnected

leftShoulder: gamepad.button

The left shoulder button

rightShoulder: gamepad.button

The right shoulder button

leftTrigger: gamepad.button

The left trigger

rightTrigger: gamepad.button

The right trigger

dpad: gamepad.directionalPad
leftStick: gamepad.directionalPad
rightStick: gamepad.directionalPad
leftStickButton: gamepad.button
rightStickButton: gamepad.button
buttonA: gamepad.button
buttonB: gamepad.button
buttonX: gamepad.button
buttonY: gamepad.button
home: gamepad.button
menu: gamepad.button
options: gamepad.button
touchpadButton: gamepad.button
touchpadSurface: gamepad.directionalPad
touchpadSurface: gamepad.directionalPad
batteryLevel: number
batteryState: const
light: color
class gamepad.button
pressing: boolean
pressed: boolean
released: boolean
value: number
touching: boolean
class gamepad.directionalPad
pressing: boolean
dir: vec2
x: number
y: number
left: boolean
right: boolean
up: boolean
down: boolean