Keybind
Represents a key binding for your script
This page is a WIP. It contains all the information in Figura's documentation but we're working on adding more helpful descriptions.
Instances are obtained using the KeybindAPI's newKeybind() function
For this entire page assuming:
local myKey = keybinds:newKeybind("Name", "key.keyboard.h", false)
Press/Release
setOnPress()
Aliases: onPress()
Sets the function that is executed when this key is pressed
The function has two arguments
The first argument is a number containing a bitmask of the currently held modifier keys
Shift = 1, Ctrl = 2, Alt = 4
The second argument is this keybind itself
setOnPress(function)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
function | Function | - | - |
Returns:
Type | Description |
---|---|
Keybind | Returns self for chaining |
Example:
myKey:setOnPress(function()
log("hi")
end)
setOnRelease()
Aliases: onRelease()
Sets the function that is executed when this key is released
The function has two arguments
The first argument is a number containing a bitmask of the currently held modifier keys
Shift = 1, Ctrl = 2, Alt = 4
The second argument is this keybind itself
setOnRelease(function)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
function | Function | - | - |
Returns:
Type | Description |
---|---|
Keybind | Returns self for chaining |
Example:
myKey:setOnRelease(function()
log("hi")
end)
isPressed()
Gets whether this keybind is currently pressed down
isPressed()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
myKey:isPressed()
Key Properties
setEnabled()
Aliases: enabled()
Toggles if this keybind should be processed or not
setEnabled(bool)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bool | Boolean | - | - |
Returns:
Type | Description |
---|---|
Keybind | Returns self for chaining |
Example:
myKey:setEnabled(true)
setGUI()
Aliases: gui()
Set whenever or not this keybind should run when a GUI screen is open
setGUI(bool)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bool | Boolean | - | - |
Returns:
Type | Description |
---|---|
Keybind | Returns self for chaining |
Example:
myKey:setGUI(true)
getID()
Returns the numeric ID of this keybind
getID()
Returns:
Type | Description |
---|---|
Integer | - |
Example:
myKey:getID()
setKey()
Aliases: key()
Sets the key for this keybind
setKey(key)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key | String | - | - |
Returns:
Type | Description |
---|---|
Keybind | Returns self for chaining |
Example:
myKey:setKey("key.keyboard.l")
getKey()
Gets the current key for this keybind
getKey()
Returns:
Type | Description |
---|---|
String | - |
Example:
myKey:getKey()
getKeyName()
Gets the name of the current key for this keybind
getKeyName()
Returns:
Type | Description |
---|---|
String | - |
Example:
myKey:getKeyName()
getName()
Gets the name of the keybind, which you set when you created the keybind
getName()
Returns:
Type | Description |
---|---|
String | - |
Example:
myKey:getName()
isDefault()
Checks whether this key is currently set to its default state (not been changed using the keybind menu)
isDefault()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
myKey:isDefault()
isEnabled()
Returns if this keybind is enabled or not
isEnabled()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
myKey:isEnabled()
isGuiEnabled()
Returns if this keybind should work when a GUI screen (Chat, Inventory, etc) is open or not
isGuiEnabled()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
myKey:isGuiEnabled()
Fields
press
A function that runs when the key is pressed down
The function has two arguments
The first argument is a number containing a bitmask of the currently held modifier keys
Shift = 1, Ctrl = 2, Alt = 4
The second argument is this keybind itself
If the return value is true then all vanilla keybinds using same key will be ignored
See setOnPress
for an example of how to set this field
release
A function that runs when the key is released
The function has two arguments
The first argument is a number containing a bitmask of the currently held modifier keys
Shift = 1, Ctrl = 2, Alt = 4
The second argument is this keybind itself
If the return value is true then all vanilla keybinds using same key will be ignored
See setOnRelease
for an example of how to set this field