Passer au contenu principal
Version: bleeding-edge 🩸

🕹️ 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
The methods, properties and events descriptions from this page are defined in our GitHub API Repository!

🎒 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
booleanIsInputEnabled
booleanIsKeyDownReturns if a key is being pressed
booleanIsMouseEnabled
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_nameThe keybinding id
InputEventinput_eventWhich event to register (Released/Pressed)
functioncallbackThe 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

GetKeyIcon

Gets the icon path of a key

— Returns string.

local ret = Input.GetKeyIcon(key_name, dark_mode?)
TypeParameterDefaultDescription
stringkey_name
booleandark_mode?false

GetMappedKeys

Returns the keys bound to a keybinding

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

local ret = Input.GetMappedKeys(binding_name)
TypeParameterDefaultDescription
stringbinding_nameThe 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_nameKey Name to input
InputEventinput_eventWhich 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

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_nameThe keybinding id
stringkey_nameThe Key to use by default if this wasn't set before
stringdescriptionText 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

See also IsInputEnabled.


SetMouseCursor

Sets the current Mouse Cursor type

Input.SetMouseCursor(cursor_type)
TypeParameterDefaultDescription
CursorTypecursor_type

SetMouseEnabled

Displays/Hides Mouse Cursor

Input.SetMouseEnabled(is_enabled)
TypeParameterDefaultDescription
booleanis_enabled

See also IsMouseEnabled.


Unbind

Unbinds all Input functions related to the given binding_name and input_event

Input.Unbind(binding_name, input_event)
TypeParameterDefaultDescription
stringbinding_nameThe keybinding id
InputEventinput_eventWhich event to register (Released/Pressed)

Unregister

Unregisters a keybinding

Input.Unregister(binding_name, key_name)
TypeParameterDefaultDescription
stringbinding_nameThe keybinding id
stringkey_name

🚀 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_name
floatmouse_x
floatmouse_y

MouseEnable

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

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_x
floatcursor_delta_y
floatmouse_x
floatmouse_y

MouseScroll

Called when the mouse scrolls
Input.Subscribe("MouseScroll", function(mouse_x, mouse_y, delta)
-- MouseScroll was called
end)
TypeArgumentDescription
floatmouse_x
floatmouse_y
floatdelta

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_name
floatmouse_x
floatmouse_y

⌨️ Noms des touches

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

▶️ Function Keys

Nom de la toucheDescription
F1Fonction une
F2Fonction deux
F3Fonction trois
F4Fonction quatre
F5Fonction cinq
F6Fonction six
F7Fonction sept
F8Fonction huit
F9Fonction neuf
F10Fonction dix
F11Fonction onze
F12Fonction douze

▶️ Alphanumerical keys

Nom de la toucheDescription
ALettre A
BLettre B
CLettre C
DLettre D
ELettre E
FLettre F
GLettre G
HLettre H
ILettre I
JLettre J
KLettre K
LLettre L
MLettre M
NLettre N
OLettre O
PLettre P
QLettre Q
RLettre R
SLettre S
TLettre T
ULettre U
VLettre V
WLettre W
XLettre X
YLettre Y
ZLettre Z

▶️ Special keys

Nom de la toucheDescription
EscapeEscape
TabTab
Tilde~
ScrollLockArrêt du défilement
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

Nom de la toucheDescription
LeftMouseButtonBouton gauche de la souris
RightMouseButtonBouton droit de la souris
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