Skip to main content
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
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)
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
Binds a function to an Input defined using Register or from the game
Returns a table with all Game KeyBindings
Gets the key code of a key
Gets the icon path of a key
of Returns the keys bound to a keybinding
Gets the currently pressed modifier keys
Returns a table with all Scripting KeyBindings
Forces an Input Key event on Local Player
No description provided
Returns if a key is being pressed
No description provided
Registers a keybinding to a default key
Resets all bound functions by this Package
Toggles Local Player input
Sets the current Mouse Cursor type
Displays/Hides Mouse Cursor
Unbinds an Input function
Unregisters a keybinding

Bind

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

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

GetGameKeyBindings

Returns a table with all Game KeyBindings

— Returns ().

local ret = Input.GetGameKeyBindings()

GetKeyCode

Gets the key code of a key

— Returns .

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

GetKeyIcon

Gets the icon path of a key

— Returns .

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

GetMappedKeys

Returns the keys bound to a keybinding

— Returns of (list of all keys).

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

GetModifierKeys

Gets the currently pressed modifier keys

— Returns .

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 ().

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
key_name Required parameter Key Name to input
input_event Required parameter Which Event to input
amount_depressed?1The amount pressed

IsInputEnabled

— Returns (if the input is visible).

local ret = Input.IsInputEnabled()

See also SetInputEnabled.


IsKeyDown

Returns if a key is being pressed

— Returns (if the key is pressed).

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

IsMouseEnabled

— Returns (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
binding_name Required parameter The keybinding id
key_name Required parameter The Key to use by default if this wasn't set before
description 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
enable_input Required parameter No description provided

See also IsInputEnabled.


SetMouseCursor

Sets the current Mouse Cursor type

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

SetMouseEnabled

Displays/Hides Mouse Cursor

Input.SetMouseEnabled(is_enabled)
TypeParameterDefaultDescription
is_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
binding_name Required parameter The keybinding id
input_event Required parameter Which event to register (Released/Pressed)
or callback Required parameter The specific function to unbind

Unregister

Unregisters a keybinding

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

🚀 Events

NameDescription
A key binding has been changed through the settings
A keyboard key is being pressed
A keyboard key has been pressed
A keyboard key has been released
A mouse button has been pressed / is being pressed
When mouse cursor is displayed/hidden
Called when the mouse moves
Called when the mouse scrolls
A 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
binding_nameThe keybinding id
keyThe new key associated
scaleThe 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
key_nameThe key pressed
or deltaThe 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
key_nameThe key pressed
or deltaThe 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
key_nameThe key pressed
or deltaThe 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
key_nameNo description provided
mouse_xNo description provided
mouse_yNo description provided

MouseEnable

When mouse cursor is displayed/hidden
Input.Subscribe("MouseEnable", function(is_enabled)
-- MouseEnable was called
end)
TypeArgumentDescription
is_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
cursor_delta_xNo description provided
cursor_delta_yNo description provided
mouse_xNo description provided
mouse_yNo description provided

MouseScroll

Called when the mouse scrolls
Input.Subscribe("MouseScroll", function(mouse_x, mouse_y, delta)
-- MouseScroll was called
end)
TypeArgumentDescription
mouse_xNo description provided
mouse_yNo description provided
deltaNo 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
key_nameNo description provided
mouse_xNo description provided
mouse_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

▶️ AZERTY

Key NameDescription
Ampersand'&'
Asterix'*'
Caret'^'
Colon':'
Dollar'$'
Exclamation'!'
LeftParantheses'('
RightParantheses')'
A_AccentGraveà
C_Cedilleç
E_AccentAigué
E_AccentGraveè