Magical ContextActionService behavior (bug?)

I’m puzzled by this behavior. I was trying to test what would happen in the case where there are multiple actions bound with the same name. To check if the most recently bound action would override the previous one. While performing this test, I noticed that the functions bound to the actions get called for no apparent reason.

local ContextActionService = game:GetService("ContextActionService")

local key = Enum.KeyCode.H

task.wait(5)

function handler(ActionName, InputState,InputObject: InputObject)
	print("run", ActionName,InputState,InputObject.KeyCode)
end

ContextActionService:BindAction("DuplicateKey", handler, false, key)

ContextActionService:BindAction("DuplicateKey", handler, false, key)

print"connected"

task.wait(5)

ContextActionService:UnbindAction("DuplicateKey")

print"disconnected"

image

This seems like a bug to me unless I’m missing something…

1 Like

idk if this is what you meant but sometimes when I press esc it triggers a context key and I have no idea how that makes sense

no bug whatsoever, intended behavior

What constitutes an “in progress” input? The handler functions will be called three times here with no input. Assuming cancel gets passed when an action is overwritten or unbound, it should fire twice, not three times. That’s the only way this makes sense since there is no in-progress input. As far as I can tell an in-progress input is the following: Input Began → Input Canceled