Psych Engine Logo
Psych Engine - Lua Script API

Input Functions

Functions for keyboard and gamepad input detection.


mouseClicked

mouseClicked(button:String = 'left'):Bool

Returns if the Mouse button just got clicked in this frame.

Examples:


mousePressed

mousePressed(button:String = 'left'):Bool

Returns if the Mouse button is being held currently.


mouseReleased

mouseReleased(button:String = 'left'):Bool

Returns if the Mouse button was just released in this frame.


getMouseX

getMouseX(camera:String = 'game'):Float

Returns Mouse's Screen X from a Camera.

Examples:


getMouseY

getMouseY(camera:String = 'game'):Float

Returns Mouse's Screen Y from a Camera.


keyJustPressed

keyJustPressed(button:String):Bool

Returns if a keybind button just got pressed on a controller or keyboard.

Examples:


keyPressed

keyPressed(button:String):Bool

Returns if a keybind button is being held on a controller or keyboard.


keyReleased

keyReleased(button:String):Bool

Returns if a keybind button was just released on a controller or keyboard.


keyboardJustPressed

keyboardJustPressed(button:String):Bool

Returns if a specific keyboard button just got pressed.

Examples:

  • keyboardJustPressed('ENTER') - Pressed Enter in your keyboard.
  • keyboardJustPressed('F5') - Pressed F5 in your keyboard.

  • keyboardPressed

    keyboardPressed(button:String):Bool

    Returns if a specific keyboard button is being pressed.


    keyboardReleased

    keyboardReleased(button:String):Bool

    Returns if a specific keyboard button was just released.


    anyGamepadJustPressed

    anyGamepadJustPressed(button:String):Bool

    Returns if a specific gamepad button just got pressed in any controllers.

    Examples:

  • anyGamepadJustPressed('DPAD_LEFT') - Pressed Arrow Left in any gamepad.
  • anyGamepadJustPressed('X') - Pressed X in any gamepad.

  • anyGamepadPressed

    anyGamepadPressed(button:String):Bool

    Returns if a specific gamepad button is being pressed in any controllers.


    anyGamepadReleased

    anyGamepadReleased(button:String):Bool

    Returns if a specific gamepad button was just released in any controllers.


    gamepadJustPressed

    gamepadJustPressed(id:Int, button:String):Bool

    Returns if a specific gamepad button just got pressed in a specific controller.

    Examples:

  • gamepadJustPressed(0, 'DPAD_LEFT') - Pressed Arrow Left in controller #1.
  • gamepadJustPressed(1, 'X') - Pressed X in in controller #2.

  • gamepadPressed

    gamepadPressed(id:Int, button:String):Bool

    Returns if a specific gamepad button is being pressed in a specific controller.


    gamepadReleased

    gamepadReleased(id:Int, button:String):Bool

    Returns if a specific gamepad button was just released in a specific controller.


    gamepadAnalogX

    gamepadAnalogX(id:Int, ?leftStick:Bool = true):Float

    Returns the Analog X value in a specific controller, ranges from -1 to 1.

    Examples:

  • gamepadAnalogX(0) - Returns Left Analog X of controller #1.
  • gamepadAnalogX(1, false) - Returns Right X Analog of controller #2.

  • gamepadAnalogY

    gamepadAnalogY(id:Int, ?leftStick:Bool = true):Float

    Returns the Analog Y value in a specific controller, ranges from -1 to 1.