Ir para o conteúdo principal
Version: latest - a1.65.x ⚖️

🕹️ Input

Create custom keybindings and retrieve input information.

🗿Static Class
This is a Static Class. Access it's methods directly with .. It's not possible to spawn new instances.
💂Authority
This static class can be accessed only on 🟧 Client side.
🧑‍💻API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!

🎒 Examples

Client/Index.lua
-- Registers the binding_name 'SpawnMenu' with default key 'Q'
-- This will add 'SpawnMenu' to user KeyBinding Settings automatically
Input.Register("SpawnMenu", "Q")

-- Subscribes for Pressing the key
Input.Bind("SpawnMenu", InputEvent.Pressed, function()
-- Opens the Spawn Menu
end)

-- Subscribes for Releasing the key
Input.Bind("SpawnMenu", InputEvent.Released, function()
-- Closes the Spawn Menu
end)
(Input.GetModifierKeys) Checks if has Shift pressed
local modifier_keys = Input.GetModifierKeys()
local has_shift_pressed = modifier_keys & KeyModifier.LeftShiftDown
-- Outputs "true"

🗿 Static Functions

ReturnsNameDescription
BindBinds a function to an Input defined using Register or from the game
tableGetGameKeyBindingsReturns a table with all Game KeyBindings
integerGetKeyCodeGets the key code of a key
stringGetKeyIconGets the icon path of a key
table of stringGetMappedKeysReturns the keys bound to a keybinding
KeyModifierGetModifierKeysGets the currently pressed modifier keys
tableGetScriptingKeyBindingsReturns a table with all Scripting KeyBindings
InputKeyForces an Input Key event on Local Player
booleanIsInputEnabledNo description provided
booleanIsKeyDownReturns if a key is being pressed
booleanIsMouseEnabledNo description provided
RegisterRegisters a keybinding to a default key
ResetBindingsResets all bound functions by this Package
SetInputEnabledToggles Local Player input
SetMouseCursorSets the current Mouse Cursor type
SetMouseEnabledDisplays/Hides Mouse Cursor
UnbindUnbinds an Input function
UnregisterUnregisters a keybinding

Bind

Binds a function to an Input defined using Register or from the game

Input.Bind(binding_name, input_event, callback)
TypeParameterDefaultDescription
stringbinding_name Required parameter The keybinding id
InputEventinput_event Required parameter Which event to register (Released/Pressed)
functioncallback Required parameter The function to trigger with this format

GetGameKeyBindings

Returns a table with all Game KeyBindings

— Returns table (with this format).

local ret = Input.GetGameKeyBindings()

GetKeyCode

Gets the key code of a key

— Returns integer.

local ret = Input.GetKeyCode(key_name)
TypeParameterDefaultDescription
stringkey_name Required parameter No description provided

GetKeyIcon

Gets the icon path of a key

— Returns string.

local ret = Input.GetKeyIcon(key_name, dark_mode?)
TypeParameterDefaultDescription
stringkey_name Required parameter No description provided
booleandark_mode?falseNo description provided

GetMappedKeys

Returns the keys bound to a keybinding

— Returns table of string (list of all keys).

local ret = Input.GetMappedKeys(binding_name)
TypeParameterDefaultDescription
stringbinding_name Required parameter The keybinding id

GetModifierKeys

Gets the currently pressed modifier keys

— Returns KeyModifier.

local ret = Input.GetModifierKeys()
Input.GetModifierKeys Examples
Checks if has Shift pressed
local modifier_keys = Input.GetModifierKeys()
local has_shift_pressed = modifier_keys & KeyModifier.LeftShiftDown
-- Outputs "true"

GetScriptingKeyBindings

Returns a table with all Scripting KeyBindings

— Returns table (with this format).

local ret = Input.GetScriptingKeyBindings()

InputKey

Forces an Input Key event on Local Player

This won't trigger any Scripting event as it bypass internal validations

Input.InputKey(key_name, input_event, amount_depressed?)
TypeParameterDefaultDescription
stringkey_name Required parameter Key Name to input
InputEventinput_event Required parameter Which Event to input
floatamount_depressed?1The amount pressed

IsInputEnabled

— Returns boolean (if the input is visible).

local ret = Input.IsInputEnabled()

See also SetInputEnabled.


IsKeyDown

Returns if a key is being pressed

— Returns boolean (if the key is pressed).

local ret = Input.IsKeyDown(key_name)
TypeParameterDefaultDescription
stringkey_name Required parameter No description provided

IsMouseEnabled

— Returns boolean (if the mouse is visible).

local ret = Input.IsMouseEnabled()

See also SetMouseEnabled.


Register

Registers a keybinding to a default key

Input.Register(binding_name, key_name, description)
TypeParameterDefaultDescription
stringbinding_name Required parameter The keybinding id
stringkey_name Required parameter The Key to use by default if this wasn't set before
stringdescription Required parameter Text to show on Key Bindings Settings

ResetBindings

Resets all bound functions by this Package

Input.ResetBindings()

SetInputEnabled

Toggles Local Player input

Input.SetInputEnabled(enable_input)
TypeParameterDefaultDescription
booleanenable_input Required parameter No description provided

See also IsInputEnabled.


SetMouseCursor

Sets the current Mouse Cursor type

Input.SetMouseCursor(cursor_type)
TypeParameterDefaultDescription
CursorTypecursor_type Required parameter No description provided

SetMouseEnabled

Displays/Hides Mouse Cursor

Input.SetMouseEnabled(is_enabled)
TypeParameterDefaultDescription
booleanis_enabled Required parameter No description provided

See also IsMouseEnabled.


Unbind

Unbinds all Input functions related to the given binding_name and input_event

Input.Unbind(binding_name, input_event, callback)
TypeParameterDefaultDescription
stringbinding_name Required parameter The keybinding id
InputEventinput_event Required parameter Which event to register (Released/Pressed)
function or nilcallback Required parameter The specific function to unbind

Unregister

Unregisters a keybinding

Input.Unregister(binding_name, key_name)
TypeParameterDefaultDescription
stringbinding_name Required parameter The keybinding id
stringkey_name Required parameter No description provided

🚀 Events

NameDescription
KeyBindingChangeA key binding has been changed through the settings
KeyDownA keyboard key is being pressed
KeyPressA keyboard key has been pressed
KeyUpA keyboard key has been released
MouseDownA mouse button has been pressed / is being pressed
MouseEnableWhen mouse cursor is displayed/hidden
MouseMoveCalled when the mouse moves
MouseScrollCalled when the mouse scrolls
MouseUpA mouse button has been released

KeyBindingChange

A key binding has been changed through the settings
Input.Subscribe("KeyBindingChange", function(binding_name, key, scale)
-- KeyBindingChange was called
end)
TypeArgumentDescription
stringbinding_nameThe keybinding id
stringkeyThe new key associated
floatscaleThe scale input (usually 1 or -1)

KeyDown

A keyboard key is being pressed

Return false to block it
Input.Subscribe("KeyDown", function(key_name, delta)
-- KeyDown was called
end)
TypeArgumentDescription
stringkey_nameThe key pressed
float or nildeltaThe amount depressed in case of this is an Axis input

KeyPress

A keyboard key has been pressed

Return false to block it
Input.Subscribe("KeyPress", function(key_name, delta)
-- KeyPress was called
end)
TypeArgumentDescription
stringkey_nameThe key pressed
float or nildeltaThe amount depressed in case of this is an Axis input

KeyUp

A keyboard key has been released

Return false to block it
Input.Subscribe("KeyUp", function(key_name, delta)
-- KeyUp was called
end)
TypeArgumentDescription
stringkey_nameThe key pressed
float or nildeltaThe amount depressed in case of this is an Axis input

MouseDown

A mouse button has been pressed / is being pressed

Return false to block it
Input.Subscribe("MouseDown", function(key_name, mouse_x, mouse_y)
-- MouseDown was called
end)
TypeArgumentDescription
stringkey_nameNo description provided
floatmouse_xNo description provided
floatmouse_yNo description provided

MouseEnable

When mouse cursor is displayed/hidden
Input.Subscribe("MouseEnable", function(is_enabled)
-- MouseEnable was called
end)
TypeArgumentDescription
booleanis_enabledNo description provided

MouseMove

Called when the mouse moves
Input.Subscribe("MouseMove", function(cursor_delta_x, cursor_delta_y, mouse_x, mouse_y)
-- MouseMove was called
end)
TypeArgumentDescription
floatcursor_delta_xNo description provided
floatcursor_delta_yNo description provided
floatmouse_xNo description provided
floatmouse_yNo description provided

MouseScroll

Called when the mouse scrolls
Input.Subscribe("MouseScroll", function(mouse_x, mouse_y, delta)
-- MouseScroll was called
end)
TypeArgumentDescription
floatmouse_xNo description provided
floatmouse_yNo description provided
floatdeltaNo description provided

MouseUp

A mouse button has been released

Return false to block it
Input.Subscribe("MouseUp", function(key_name, mouse_x, mouse_y)
-- MouseUp was called
end)
TypeArgumentDescription
stringkey_nameNo description provided
floatmouse_xNo description provided
floatmouse_yNo description provided

⌨️ Key Names

List of all keys names returned in Key/Mouse events.

▶️ Function Keys

Key NameDescription
F1Function one
F2Function two
F3Function three
F4Function four
F5Function five
F6Function six
F7Function seven
F8Function eight
F9Function nine
F10Function ten
F11Function eleven
F12Function twelve

▶️ Alphanumerical keys

Key NameDescription
ALetter A
BLetter B
CLetter C
DLetter D
ELetter E
FLetter F
GLetter G
HLetter H
ILetter I
JLetter J
KLetter K
LLetter L
MLetter M
NLetter N
OLetter O
PLetter P
QLetter Q
RLetter R
SLetter S
TLetter T
ULetter U
VLetter V
WLetter W
XLetter X
YLetter Y
ZLetter Z

▶️ Special keys

Key NameDescription
EscapeEscape
TabTab
Tilde~
ScrollLockScroll lock
PausePause
BackSpaceBackSpace
OneOne
TwoTwo
ThreeThree
FourFour
FiveFive
SixSix
SevenSeven
EightEight
NineNine
ZeroZero
Underscore_
Equals=
Backslash
LeftBracket[
RightBracket]
EnterEnter or Numpad enter
CapsLockCaps lock
Semicolon;
Quote
LeftShiftLeft shift
Comma,
Period.
Slash/
RightShiftRight Shif
LeftControlLeft control
LeftAltLeft alt
SpaceBarSpace bar
RightAltRight alt
RightControlRight control
LeftLeft
UpUp
DownDown
RightRight
HomeHome
EndEnd
InsertInsert
PageUpPage up
DeleteDelete
PageDownPage down
NumLockNum lock
DivideNumpad /
MultiplyNumpad *
SubtractNumpad -
AddNumpad +
PageDownPage down
NumPadOneNumpad one
NumPadTwoNumpad two
NumPadThreeNumpad three
NumPadFourNumpad four
NumPadFiveNumpad five
NumPadSixNumpad six
NumPadSevenNumpad seven
NumPadEightNumpad eight
NumPadNineNumpad nine
NumPadZeroNumpad zero
DecimalNumpad decimal

▶️ Mouse

Key NameDescription
LeftMouseButtonLeft mouse button
RightMouseButtonRight mouse button
MiddleMouseButtonMiddle mouse button
ThumbMouseButtonPrimary mouse thumb button
ThumbMouseButton2Secondary mouse thumb button
MouseScrollUpMouse wheel scrolling up
MouseScrollDownMouse wheel scrolling down
MouseXMouse movement on the X axis
MouseYMouse movement on the Y axis