Zum Hauptinhalt springen
Version: bleeding-edge 🩸

🕹️ Input

Create custom keybindings and retrieve input information.

🗿Static ClassClient Only🧑‍💻API Source

🎒 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)
Client/Index.lua
-- Subscribes for native Bindings
Input.Bind("MoveForward", InputEvent.Pressed, function(delta)
-- Pressed MoveForward key (usually W)
end)

-- Subscribes for native Bindings
Input.Bind("MoveBackward", InputEvent.Pressed, function(delta)
-- Pressed MoveBackward key (usually S)
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
KeyboardLayoutGetKeyboardLayoutGets the keyboard layout of the user
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
CursorTypeGetMouseCursorGets the current Mouse Cursor type
tableGetScriptingKeyBindingsReturns a table with all Scripting KeyBindings
InputKeyForces an Input Key event on Local Player
booleanIsBindingDownReturns if a Key Binding is being pressed
booleanIsInputEnabledGets if the game input is enabled
booleanIsKeyDownReturns if a key is being pressed
booleanIsMouseEnabledGets if the mouse cursor is enabled
RegisterRegisters a keybinding to a default key
ResetBindingsResets all bound functions by this Package
SetInputEnabledToggles Local Player input
SetMouseCursorSets the current Mouse Cursor type
SetMouseEnabledShows or hides the mouse cursor
functionSubscribeSubscribes to an Event
UnbindUnbinds an Input function
UnregisterUnregisters a keybinding
UnsubscribeUnsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback

Optimal

Bind​

Binds a function to an Input defined using Register or from the game
Input.Bind(binding_name, input_event, callback)

Parameters

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

Moderate

GetGameKeyBindings​

Returns a table with all Game KeyBindings
local ret = Input.GetGameKeyBindings()

Returns

TypeDescription
tableTable with all Game KeyBindings with this format

Optimal

GetKeyboardLayout​

Gets the keyboard layout of the user
local ret = Input.GetKeyboardLayout()

Returns

TypeDescription
KeyboardLayoutKeyboard layout of the user

Optimal

GetKeyCode​

Gets the key code of a key
local ret = Input.GetKeyCode(key_name)

Parameters

TypeParameterDefaultDescription
stringkey_name Required parameter The key name, e.g. E or LeftMouseButton

Returns

TypeDescription
integerKey code of a key

Optimal

GetKeyIcon​

Gets the icon path of a key
local ret = Input.GetKeyIcon(key_name, dark_mode?)

Parameters

TypeParameterDefaultDescription
stringkey_name Required parameter The key name, e.g. E or LeftMouseButton
booleandark_mode?false
Whether to return the dark version of the icon

Returns

TypeDescription
stringIcon path of a key

Moderate

GetMappedKeys​

Returns the keys bound to a keybinding
local ret = Input.GetMappedKeys(binding_name)

Parameters

TypeParameterDefaultDescription
stringbinding_name Required parameter The keybinding id

Returns

TypeDescription
table of stringlist of all keys

Optimal

GetModifierKeys​

Gets the currently pressed modifier keys
local ret = Input.GetModifierKeys()

Returns

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

Optimal

GetMouseCursor​

Gets the current Mouse Cursor type
local ret = Input.GetMouseCursor()

Returns

TypeDescription
CursorTypethe current Cursor type

See also SetMouseCursor.


Moderate

GetScriptingKeyBindings​

Returns a table with all Scripting KeyBindings
local ret = Input.GetScriptingKeyBindings()

Returns

TypeDescription
tableTable with all Scripting KeyBindings with this format

Moderate

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?)

Parameters

TypeParameterDefaultDescription
stringkey_name Required parameter Key Name to input
InputEventinput_event Required parameter Which Event to input
floatamount_depressed?1
The amount pressed

Optimal

IsBindingDown​

Returns if a Key Binding is being pressed.

A Binding can be mapped to more than one Key, any of them being pressed is enough for this to return true.
local ret = Input.IsBindingDown(binding_name)

Parameters

TypeParameterDefaultDescription
stringbinding_name Required parameter The name of the Key Binding

Returns

TypeDescription
booleanif the Key Binding is pressed

Optimal

IsInputEnabled​

Gets if the game input is enabled
local ret = Input.IsInputEnabled()

Returns

TypeDescription
booleanif the input is visible

See also SetInputEnabled.


Optimal

IsKeyDown​

Returns if a key is being pressed
local ret = Input.IsKeyDown(key_name)

Parameters

TypeParameterDefaultDescription
stringkey_name Required parameter The key name, e.g. E or LeftMouseButton

Returns

TypeDescription
booleanif the key is pressed

Optimal

IsMouseEnabled​

Gets if the mouse cursor is enabled
local ret = Input.IsMouseEnabled()

Returns

TypeDescription
booleanif the mouse is visible

See also SetMouseEnabled.


Optimal

Register​

Registers a keybinding to a default key
Input.Register(binding_name, key_name, description)

Parameters

TypeParameterDefaultDescription
stringbinding_name Required parameter The keybinding id
stringkey_name Required parameter The Key to use by default if this wasn't set before
string or nildescription Required parameter Text to show on Key Bindings Settings

Optimal

ResetBindings​

Resets all bound functions by this Package
Input.ResetBindings()

Optimal

SetInputEnabled​

Toggles Local Player input
Input.SetInputEnabled(enable_input)

Parameters

TypeParameterDefaultDescription
booleanenable_input Required parameter Whether to enable Local Player input

See also IsInputEnabled.


Optimal

SetMouseCursor​

Sets the current Mouse Cursor type
Input.SetMouseCursor(cursor_type)

Parameters

TypeParameterDefaultDescription
CursorTypecursor_type Required parameter The new current Mouse Cursor type

See also GetMouseCursor.


Optimal

SetMouseEnabled​

Shows or hides the mouse cursor
Input.SetMouseEnabled(is_enabled)

Parameters

TypeParameterDefaultDescription
booleanis_enabled Required parameter Whether the mouse cursor is enabled

See also IsMouseEnabled.


Optimal

Subscribe​

Subscribes to an Event
local ret = Input.Subscribe(event_name, callback)

Parameters

TypeParameterDefaultDescription
stringevent_name Required parameter Event to subscribe to
functioncallback Required parameter Callback to run on the event occurring

Returns

TypeDescription
functionThe function callback

Optimal

Unbind​

Unbinds all Input functions related to the given binding_name and input_event
Input.Unbind(binding_name, input_event, callback?)

Parameters

TypeParameterDefaultDescription
stringbinding_name Required parameter The keybinding id
InputEventinput_event Required parameter Which event to register (Released/Pressed)
functioncallback?nil
The specific function to unbind

Optimal

Unregister​

Unregisters a keybinding
Input.Unregister(binding_name)

Parameters

TypeParameterDefaultDescription
stringbinding_name Required parameter The keybinding id

Optimal

Unsubscribe​

Unsubscribes from all subscribed Events in this Class and in this Package, optionally passing the function to unsubscribe only that callback
Input.Unsubscribe(event_name, callback?)

Parameters

TypeParameterDefaultDescription
stringevent_name Required parameter Event to unsubscribe to
functioncallback?nil
Optional callback to specifically unsubscribe to

🚀 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)

Arguments

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
return true
end)

Arguments

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
return true
end)

Arguments

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
return true
end)

Arguments

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
return true
end)

Arguments

TypeArgumentDescription
stringkey_nameThe key name, e.g. E or LeftMouseButton
floatmouse_xMouse X position on screen, in pixels
floatmouse_yMouse Y position on screen, in pixels

MouseEnable​

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

Arguments

TypeArgumentDescription
booleanis_enabledWhether the cursor is now displayed

MouseMove​

Called when the mouse moves

Return false to block it
Input.Subscribe("MouseMove", function(cursor_delta_x, cursor_delta_y, mouse_x, mouse_y)
-- MouseMove was called
return true
end)

Arguments

TypeArgumentDescription
floatcursor_delta_xHorizontal movement since the last event
floatcursor_delta_yVertical movement since the last event
floatmouse_xMouse X position on screen, in pixels
floatmouse_yMouse Y position on screen, in pixels

MouseScroll​

Called when the mouse scrolls

Return false to block it
Input.Subscribe("MouseScroll", function(mouse_x, mouse_y, delta)
-- MouseScroll was called
return true
end)

Arguments

TypeArgumentDescription
floatmouse_xMouse X position on screen, in pixels
floatmouse_yMouse Y position on screen, in pixels
floatdeltaScroll amount, positive when scrolling up and negative when scrolling down

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
return true
end)

Arguments

TypeArgumentDescription
stringkey_nameThe key name, e.g. E or LeftMouseButton
floatmouse_xMouse X position on screen, in pixels
floatmouse_yMouse Y position on screen, in pixels

⌨️ 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 Shift
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 +
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

▶️ AZERTY​

Key NameDescription
Ampersand&
Asterix-
Caret^
Colon:
Dollar$
Exclamation!
LeftParantheses(
RightParantheses)
A_AccentGraveÀ
C_CedilleÇ
E_AccentAiguÉ
E_AccentGraveÈ