Community Forum

registerActionEvents for Keybinds

Forum Overview >> Scripting

Created08.03.2021 23:37

Landry Strickland (WPCom) 08.03.2021 23:37
Hello everyone and good afternoon,

I am looking to be pointed in the right direction for handling multiple key binds. The only issue I am having is how to go about registering multiple Action events. I have the following:

function WPToolKit:registerActionEvents() = {}

local result, eventName = InputBinding.registerActionEvent(g_inputBinding, "STRONGFARMER", self, WPToolKit.toggleStrongFarmer, false, true, false, true)

if result then
table.insert(, eventName)
g_inputBinding:setActionEventTextVisibility(eventName, true)
g_inputBinding:setActionEventTextPriority(eventName, GS_PRIO_NORMAL)


I am looking to add another key bind with the action name RESETVEHICLE. I know there are mods that do both the items I have listed; however I am here to learn. I have looked at few other mods and see that each mod seems to handle key binds a little differently. I have looked through the documentation and do not see anything on the InputBinding class to get more information on the registerActionEvents function, so I am also not sure what the true false args are representing.

Any guidance in the area would be appreciated!

Bilbo Beutlin (BBeutlin) 09.03.2021 15:44
The general format is
eventAdded, eventId = g_inputBinding:registerActionEvent(actionId, self, callback, triggerUp, triggerDown, triggerAlways, startActive, callbackState, flag)
The last 'flag' is conflict removal flag, will disable conflicting bindings of newly registered actions.

For reference see

I'm not sure what you mean with "multiple key binds".
You can add any further action to your function callback. Certainly this must have a unique actionId since each input action needs a dedicated actionId.
What you have defined in modDesc as <action name="something" you can refer as actionId with 'InputAction.something'.

Note: Log in to post. Create a new account here.