util.input.unbind
Client
Unregisters a previously bound handler from a key or mouse button input
Syntax
local status = util.input.unbind(
key,
direction,
exec
)Parameters
| Type | Name | Description |
|---|---|---|
util.input.key | key | Key or button the handler was bound to: • Refer util.input.key enum |
string | direction | Input phase the handler was registered for: • When "down" - triggers while the key is held• When "up" - triggers when the key is released |
function | exec | Handler functionto remove Must be the same function value passed to util.input.bind |
Returns
| Type | Name | Description |
|---|---|---|
bool | status | true if the handler was found and removed, false otherwise |
Examples
local function on_jump(key, direction)
core.engine.print("info", "Jump triggered")
end
util.input.bind(util.input.key.SPACE, "down", on_jump)
-- Remove when no longer needed
util.input.unbind(util.input.key.SPACE, "down", on_jump)local handler
handler = function(key, direction)
core.engine.print("info", "Fired once, then removed")
util.input.unbind(util.input.key.F, "down", handler)
end
util.input.bind(util.input.key.F, "down", handler)