Skip to main content

Keybind

Represents a key binding for your script

warning

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:

NameTypeDescriptionDefault
functionFunction--

Returns:

TypeDescription
KeybindReturns 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:

NameTypeDescriptionDefault
functionFunction--

Returns:

TypeDescription
KeybindReturns self for chaining

Example:

myKey:setOnRelease(function()
log("hi")
end)

isPressed()

Gets whether this keybind is currently pressed down

isPressed()

Returns:

TypeDescription
Boolean-

Example:

myKey:isPressed()

Key Properties

setEnabled()

Aliases: enabled()

Toggles if this keybind should be processed or not

setEnabled(bool)

Parameters:

NameTypeDescriptionDefault
boolBoolean--

Returns:

TypeDescription
KeybindReturns 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:

NameTypeDescriptionDefault
boolBoolean--

Returns:

TypeDescription
KeybindReturns self for chaining

Example:

myKey:setGUI(true)

getID()

Returns the numeric ID of this keybind

getID()

Returns:

TypeDescription
Integer-

Example:

myKey:getID()

setKey()

Aliases: key()

Sets the key for this keybind

setKey(key)

Parameters:

NameTypeDescriptionDefault
keyString--

Returns:

TypeDescription
KeybindReturns self for chaining

Example:

myKey:setKey("key.keyboard.l")

getKey()

Gets the current key for this keybind

getKey()

Returns:

TypeDescription
String-

Example:

myKey:getKey()

getKeyName()

Gets the name of the current key for this keybind

getKeyName()

Returns:

TypeDescription
String-

Example:

myKey:getKeyName()

getName()

Gets the name of the keybind, which you set when you created the keybind

getName()

Returns:

TypeDescription
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:

TypeDescription
Boolean-

Example:

myKey:isDefault()

isEnabled()

Returns if this keybind is enabled or not

isEnabled()

Returns:

TypeDescription
Boolean-

Example:

myKey:isEnabled()

isGuiEnabled()

Returns if this keybind should work when a GUI screen (Chat, Inventory, etc) is open or not

isGuiEnabled()

Returns:

TypeDescription
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