Skip to main content

Input

The Input class used to define input axes

Functions

read

Input:read(controllernumber?) → T,T

Reads current and previous values for the axis

local current, previous = attack:read()  

pressing

Input:pressing(controllernumber?) → boolean

Gets whether the axis has any active input

changed

Input:changed(controllernumber?) → boolean

Gets whether an axis has changed since the last update

pressed

Input:pressed(controllernumber?) → boolean

Gets whether the axis was activated this update

released

Input:released(controllernumber?) → boolean

Gets whether the axis was deactivated this update

hold

Input:hold(
valueT,
controllernumber?
) → () → ()

Adds a temporary manual input to the axis, and provides a function to release it

local release = attack:hold(1) -- adds 1 to the axis
--release later
release() -- removes the added value

move

Input:move(
valueT,
controllernumber?
) → ()

Adds an input to the axis for a single frame

map

Input:map(keyMapMap<T>) → ()

Maps input types to an input axis

attack:map {
	Enum.KeyCode.Q,
	Enum.KeyCode.ButtonA,
}
-- or to clear all input mappings
attack:map {}

update

Input:update() → ()

Updates the current and previous values of the input axis

Show raw api
{
    "functions": [
        {
            "name": "read",
            "desc": "Reads current and previous values for the axis\n```lua\nlocal current, previous = attack:read()  \n```",
            "params": [
                {
                    "name": "controller",
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "T, T"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 54,
                "path": "src/input.luau"
            }
        },
        {
            "name": "pressing",
            "desc": "Gets whether the axis has any active input",
            "params": [
                {
                    "name": "controller",
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 66,
                "path": "src/input.luau"
            }
        },
        {
            "name": "changed",
            "desc": "Gets whether an axis has changed since the last update",
            "params": [
                {
                    "name": "controller",
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 79,
                "path": "src/input.luau"
            }
        },
        {
            "name": "pressed",
            "desc": "Gets whether the axis was activated this update",
            "params": [
                {
                    "name": "controller",
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 90,
                "path": "src/input.luau"
            }
        },
        {
            "name": "released",
            "desc": "Gets whether the axis was deactivated this update",
            "params": [
                {
                    "name": "controller",
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 101,
                "path": "src/input.luau"
            }
        },
        {
            "name": "hold",
            "desc": "Adds a temporary manual input to the axis, and provides a function to release it\n```lua\nlocal release = attack:hold(1) -- adds 1 to the axis\n--release later\nrelease() -- removes the added value\n```",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "T"
                },
                {
                    "name": "controller",
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "() -> ()"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 118,
                "path": "src/input.luau"
            }
        },
        {
            "name": "move",
            "desc": "Adds an input to the axis for a single frame",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "T"
                },
                {
                    "name": "controller",
                    "desc": "",
                    "lua_type": "number?"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 134,
                "path": "src/input.luau"
            }
        },
        {
            "name": "map",
            "desc": "Maps input types to an input axis\n```lua\nattack:map {\n\tEnum.KeyCode.Q,\n\tEnum.KeyCode.ButtonA,\n}\n-- or to clear all input mappings\nattack:map {}\n```",
            "params": [
                {
                    "name": "keyMap",
                    "desc": "",
                    "lua_type": "Map<T>"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 156,
                "path": "src/input.luau"
            }
        },
        {
            "name": "update",
            "desc": "Updates the current and previous values of the input axis",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 267,
                "path": "src/input.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Input",
    "desc": "The Input class used to define input axes",
    "source": {
        "line": 7,
        "path": "src/input.luau"
    }
}