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

TypeNameDescription
util.input.keykeyKey or button the handler was bound to:
• Refer util.input.key enum
stringdirectionInput phase the handler was registered for:
• When "down" - triggers while the key is held
• When "up" - triggers when the key is released
functionexecHandler functionto remove
Must be the same function value passed to util.input.bind

Returns

TypeNameDescription
boolstatustrue if the handler was found and removed, false otherwise

Examples

Unbind a previously registered handler
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)
Self-unbinding one-shot handler
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)

On this page