Here is a way to securely mimic the console variable
ActionButtonUseKeyDown, so that custom action bars (beyond the default UI range) can respond during combat to key-press (down) and mouse-release (up).
This workaround starts by setting the keybind to something obscure like Button31, and using SetAttribute("Button31", "") so that the keybind basically does nothing. Then, a secure wrapper (made possible via SecureHandlerBaseTemplate) will check if it is a down stroke and convert it to LeftButton so that the action can trigger as if it were a mouse click.
(Mimicking LeftButton also allows users to write [btn:1] in macros and have it fire via the obscure keybinding.)
Lua Code:
-- create a typical action button... but also inherit SecureHandlerBaseTemplate
local button = CreateFrame("CheckButton", "myActionButton80", nil, "SecureActionButtonTemplate,SecureHandlerBaseTemplate")
button:SetAttribute("type", "action")
button:SetAttribute("action", 80)
-- give it an obscure keybinding, and register it to do nothing
SetBinding("SHIFT-Q", "CLICK myActionButton80:Button31")
button:RegisterForClicks("AnyUp", "Button31Down")
button:SetAttribute("type31", "")
-- Here is the magic to convert a key-down into LeftButton
button:WrapScript(button, "OnClick", [=[
-- self, button, down
if (button == "Button31" and down) then
return "LeftButton"
end
]=])