Skip to main content

Keybind

Represents a key binding for your script

Instances are obtained using the KeybindAPI's newKeybind() function

For this entire page assume:

local myKey = keybinds:newKeybind("Name", "key.keyboard.h", false)

Press/Release​

setOnPress(fn)​

Sets the function that is executed when this key is pressed

The function has two arguments

The first argument is a number, meaning the modifiers bitmask

Shift = 1, Ctrl = 2, Alt = 4

The second argument is this keybind itself

Example:

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

setOnRelease(fn)​

Sets the function that is executed when this key is released

The function has two arguments

The first argument is a number, meaning the modifiers bitmask

Shift = 1, Ctrl = 2, Alt = 4

The second argument is this keybind itself

Example:

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

isPressed()​

Gets whether this keybind is currently pressed down

Example:

myKey:isPressed()

Key Properites​

setKey(string)​

Sets the key for this keybind

Example:

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

getKey()​

Gets the current key for this keybind

Example:

myKey:getKey()

isDefault()​

Checks whether this key is currently set to its default state (not been changed using the keybind menu)

Example:

myKey:isDefault()

getName()​

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

Example:

myKey:getName()

getKeyName()​

Gets the name of the current key for this keybind

Example:

myKey:getKeyName()

getID()​

Returns the numeric ID of this keybind

Example:

myKey:getID()

setEnabled(bool)​

Toggles if this keybind should be processed or not

Example:

myKey:setEnabled(true)

isEnabled()​

Returns if this keybind is enabled or not

Example:

myKey:isEnabled()

setGUI(bool)​

Set whenever or not this keybind should run when a GUI screen is open

Example:

myKey:setGUI(true)

isGuiEnabled()​

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

Example:

myKey:isGuiEnabled()