Skip to content

K.Input ​

Functions ​

K.Input.Bind ​

lua
K.Input.Bind(name: string, keys: any, third: any, fourth: any): Action

Bind(name, keys, callback?) or Bind(name, keys, options, callback?). The callback runs on press. Binding a name again replaces the old action.

K.Input.Get ​

lua
K.Input.Get(name: string): Action?

The action bound with this name, or nil.

K.Input.IsDown ​

lua
K.Input.IsDown(key: any): boolean

True while the key or mouse button is held.

K.Input.Device ​

lua
K.Input.Device(): string

"Keyboard" (keyboard and mouse), "Gamepad" or "Touch": whatever the player used last.

K.Input.OnDeviceChanged ​

lua
K.Input.OnDeviceChanged(callback: (string) -> ())

Runs callback(device) when the player switches between keyboard, gamepad and touch.

K.Input.Aim ​

lua
K.Input.Aim(maxDistance: number?): (Vector3, BasePart?)

Where the mouse or last touch points in the world (screen center on gamepad). Returns the position and the part hit (nil if it points at the sky). Ignores your own character.

Methods on action ​

action:OnPress ​

lua
action:OnPress(callback: (InputObject?) -> ())

Runs callback(inputObject) when any of the action's keys is pressed.

action:OnRelease ​

lua
action:OnRelease(callback: (InputObject?) -> ())

Runs callback(inputObject) when the key is let go.

action:Send ​

lua
action:Send(eventName: string, ...: any)

On press, fires the Net event eventName to the server with any extra values.

action:IsDown ​

lua
action:IsDown(): boolean

action:Rebind ​

lua
action:Rebind(keys: any)

Changes the keys, e.g. from a settings menu.

action:Disable ​

lua
action:Disable()

action:Enable ​

lua
action:Enable()

action:Unbind ​

lua
action:Unbind()

Removes the action completely.

Generated from src/Corode/Input.luau.

Corode 0.13.0 · MIT License