🕹️ 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
Returns | Name | Description | |
---|---|---|---|
Bind | Binds a function to an Input defined using Register or from the game | ||
table | GetGameKeyBindings | Returns a table with all Game KeyBindings | |
integer | GetKeyCode | Gets the key code of a key | |
string | GetKeyIcon | Gets the icon path of a key | |
table of string | GetMappedKeys | Returns the keys bound to a keybinding | |
KeyModifier | GetModifierKeys | Gets the currently pressed modifier keys | |
table | GetScriptingKeyBindings | Returns a table with all Scripting KeyBindings | |
InputKey | Forces an Input Key event on Local Player | ||
boolean | IsInputEnabled | No description provided | |
boolean | IsKeyDown | Returns if a key is being pressed | |
boolean | IsMouseEnabled | No description provided | |
Register | Registers a keybinding to a default key | ||
ResetBindings | Resets all bound functions by this Package | ||
SetInputEnabled | Toggles Local Player input | ||
SetMouseCursor | Sets the current Mouse Cursor type | ||
SetMouseEnabled | Displays/Hides Mouse Cursor | ||
Unbind | Unbinds an Input function | ||
Unregister | Unregisters a keybinding |
Bind
Binds a function to an Input defined using Register
or from the game
Input.Bind(binding_name, input_event, callback)
Type | Parameter | Default | Description |
---|---|---|---|
string | binding_name | Required parameter | The keybinding id |
InputEvent | input_event | Required parameter | Which event to register (Released/Pressed) |
function | callback | 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)
Type | Parameter | Default | Description |
---|---|---|---|
string | key_name | Required parameter | No description provided |
GetKeyIcon
Gets the icon path of a key
— Returns string.
local ret = Input.GetKeyIcon(key_name, dark_mode?)
Type | Parameter | Default | Description |
---|---|---|---|
string | key_name | Required parameter | No description provided |
boolean | dark_mode? | false | No description provided |
GetMappedKeys
Returns the keys bound to a keybinding
— Returns table of string (list of all keys).
local ret = Input.GetMappedKeys(binding_name)
Type | Parameter | Default | Description |
---|---|---|---|
string | binding_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?)
Type | Parameter | Default | Description |
---|---|---|---|
string | key_name | Required parameter | Key Name to input |
InputEvent | input_event | Required parameter | Which Event to input |
float | amount_depressed? | 1 | The 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)
Type | Parameter | Default | Description |
---|---|---|---|
string | key_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)
Type | Parameter | Default | Description |
---|---|---|---|
string | binding_name | Required parameter | The keybinding id |
string | key_name | Required parameter | The Key to use by default if this wasn't set before |
string | 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)
Type | Parameter | Default | Description |
---|---|---|---|
boolean | enable_input | Required parameter | No description provided |
See also IsInputEnabled.
SetMouseCursor
Sets the current Mouse Cursor type
Input.SetMouseCursor(cursor_type)
Type | Parameter | Default | Description |
---|---|---|---|
CursorType | cursor_type | Required parameter | No description provided |
SetMouseEnabled
Displays/Hides Mouse Cursor
Input.SetMouseEnabled(is_enabled)
Type | Parameter | Default | Description |
---|---|---|---|
boolean | 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)
Type | Parameter | Default | Description |
---|---|---|---|
string | binding_name | Required parameter | The keybinding id |
InputEvent | input_event | Required parameter | Which event to register (Released/Pressed) |
function or nil | callback | Required parameter | The specific function to unbind |
Unregister
Unregisters a keybinding
Input.Unregister(binding_name, key_name)
Type | Parameter | Default | Description |
---|---|---|---|
string | binding_name | Required parameter | The keybinding id |
string | key_name | Required parameter | No description provided |
🚀 Events
Name | Description | |
---|---|---|
KeyBindingChange | A key binding has been changed through the settings | |
KeyDown | A keyboard key is being pressed | |
KeyPress | A keyboard key has been pressed | |
KeyUp | A keyboard key has been released | |
MouseDown | A mouse button has been pressed / is being pressed | |
MouseEnable | When mouse cursor is displayed/hidden | |
MouseMove | Called when the mouse moves | |
MouseScroll | Called when the mouse scrolls | |
MouseUp | 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)
Type | Argument | Description |
---|---|---|
string | binding_name | The keybinding id |
string | key | The new key associated |
float | scale | The 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)
Type | Argument | Description |
---|---|---|
string | key_name | The key pressed |
float or nil | delta | The 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)
Type | Argument | Description |
---|---|---|
string | key_name | The key pressed |
float or nil | delta | The 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)
Type | Argument | Description |
---|---|---|
string | key_name | The key pressed |
float or nil | delta | The 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)
Type | Argument | Description |
---|---|---|
string | key_name | No description provided |
float | mouse_x | No description provided |
float | mouse_y | No description provided |
MouseEnable
When mouse cursor is displayed/hidden
Input.Subscribe("MouseEnable", function(is_enabled)
-- MouseEnable was called
end)
Type | Argument | Description |
---|---|---|
boolean | is_enabled | No 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)
Type | Argument | Description |
---|---|---|
float | cursor_delta_x | No description provided |
float | cursor_delta_y | No description provided |
float | mouse_x | No description provided |
float | mouse_y | No description provided |
MouseScroll
Called when the mouse scrolls
Input.Subscribe("MouseScroll", function(mouse_x, mouse_y, delta)
-- MouseScroll was called
end)
Type | Argument | Description |
---|---|---|
float | mouse_x | No description provided |
float | mouse_y | No description provided |
float | delta | No 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)
Type | Argument | Description |
---|---|---|
string | key_name | No description provided |
float | mouse_x | No description provided |
float | mouse_y | No description provided |
⌨️ Key Names
List of all keys names returned in Key/Mouse events.
▶️ Function Keys
Key Name | Beschreibung |
---|---|
F1 | Function one |
F2 | Function two |
F3 | Function three |
F4 | Function four |
F5 | Function five |
F6 | Function six |
F7 | Function seven |
F8 | Function eight |
F9 | Function nine |
F10 | Function ten |
F11 | Function eleven |
F12 | Function twelve |
▶️ Alphanumerical keys
Key Name | Beschreibung |
---|---|
A | Letter A |
B | Letter B |
C | Letter C |
D | Letter D |
E | Letter E |
F | Letter F |
G | Letter G |
H | Letter H |
I | Letter I |
J | Letter J |
K | Letter K |
L | Letter L |
M | Letter M |
N | Letter N |
O | Letter O |
P | Letter P |
Q | Letter Q |
R | Letter R |
S | Letter S |
T | Letter T |
U | Letter U |
V | Letter V |
W | Letter W |
X | Letter X |
Y | Letter Y |
Z | Letter Z |
▶️ Special keys
Key Name | Beschreibung |
---|---|
Escape | Escape |
Tab | Tab |
Tilde | ~ |
ScrollLock | Scroll lock |
Pause | Pause |
BackSpace | BackSpace |
One | One |
Two | Two |
Three | Three |
Four | Four |
Five | Five |
Six | Six |
Seven | Seven |
Eight | Eight |
Nine | Nine |
Zero | Zero |
Underscore | _ |
Equals | = |
Backslash | |
LeftBracket | [ |
RightBracket | ] |
Enter | Enter or Numpad enter |
CapsLock | Caps lock |
Semicolon | ; |
Quote | ‘ |
LeftShift | Left shift |
Comma | , |
Period | . |
Slash | / |
RightShift | Right Shif |
LeftControl | Left control |
LeftAlt | Left alt |
SpaceBar | Space bar |
RightAlt | Right alt |
RightControl | Right control |
Left | Left |
Up | Up |
Down | Down |
Right | Right |
Home | Home |
End | End |
Insert | Insert |
PageUp | Page up |
Delete | Delete |
PageDown | Page down |
NumLock | Num lock |
Divide | Numpad / |
Multiply | Numpad * |
Subtract | Numpad - |
Add | Numpad + |
PageDown | Page down |
NumPadOne | Numpad one |
NumPadTwo | Numpad two |
NumPadThree | Numpad three |
NumPadFour | Numpad four |
NumPadFive | Numpad five |
NumPadSix | Numpad six |
NumPadSeven | Numpad seven |
NumPadEight | Numpad eight |
NumPadNine | Numpad nine |
NumPadZero | Numpad zero |
Decimal | Numpad decimal |
▶️ Mouse
Key Name | Beschreibung |
---|---|
LeftMouseButton | Left mouse button |
RightMouseButton | Right mouse button |
MiddleMouseButton | Middle mouse button |
ThumbMouseButton | Primary mouse thumb button |
ThumbMouseButton2 | Secondary mouse thumb button |
MouseScrollUp | Mouse wheel scrolling up |
MouseScrollDown | Mouse wheel scrolling down |
MouseX | Mouse movement on the X axis |
MouseY | Mouse movement on the Y axis |