<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.returnofreckoning.com/index.php?action=history&amp;feed=atom&amp;title=API%3AGetBindingsForAction</id>
	<title>API:GetBindingsForAction - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.returnofreckoning.com/index.php?action=history&amp;feed=atom&amp;title=API%3AGetBindingsForAction"/>
	<link rel="alternate" type="text/html" href="https://wiki.returnofreckoning.com/index.php?title=API:GetBindingsForAction&amp;action=history"/>
	<updated>2026-10-18T04:54:04Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.returnofreckoning.com/index.php?title=API:GetBindingsForAction&amp;diff=30344&amp;oldid=prev</id>
		<title>Maintenance script: UI Lua API import (WAR 1.4.8)</title>
		<link rel="alternate" type="text/html" href="https://wiki.returnofreckoning.com/index.php?title=API:GetBindingsForAction&amp;diff=30344&amp;oldid=prev"/>
		<updated>2026-10-16T19:43:04Z</updated>

		<summary type="html">&lt;p&gt;UI Lua API import (WAR 1.4.8)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{LuaApi|group=Game}}&lt;br /&gt;
Returns every key or button combination bound to an action.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bindings = GetBindingsForAction(actionName)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Arguments ==&lt;br /&gt;
;actionName : &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; – Name of the action. Compared without regard to case.&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
;bindings : &amp;lt;code&amp;gt;table&amp;lt;/code&amp;gt; – Array of binding tables, indexed from 1. Empty if the action has no bindings or the name is unknown.&lt;br /&gt;
&lt;br /&gt;
Each binding table has these fields:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Key !! Type !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;deviceId&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt; || Input device of the binding. Compare with &amp;lt;code&amp;gt;SystemData.InputDevice&amp;lt;/code&amp;gt; values, for example &amp;lt;code&amp;gt;SystemData.InputDevice.KEYBOARD&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;buttons&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;table&amp;lt;/code&amp;gt; || Array of button ids (&amp;lt;code&amp;gt;number&amp;lt;/code&amp;gt;) that make up the combination, indexed from 1.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Details ==&lt;br /&gt;
* An unknown action name returns an empty table. It is not an error.&lt;br /&gt;
* Pass &amp;lt;code&amp;gt;deviceId&amp;lt;/code&amp;gt; and each button id to [[API:GetButtonName|GetButtonName]] to get a readable name.&lt;br /&gt;
* In the stock UI, all buttons before the last one in a combination are treated as keyboard modifiers (see the example).&lt;br /&gt;
&lt;br /&gt;
== Errors ==&lt;br /&gt;
None.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
From &amp;lt;code&amp;gt;KeyUtils.GetBindingsForAction&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;easystem_utils/source/keyutils.lua&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local boundKeys = GetBindingsForAction( action )&lt;br /&gt;
...&lt;br /&gt;
for bindingCount, bindingData in ipairs( boundKeys )&lt;br /&gt;
do&lt;br /&gt;
    ...&lt;br /&gt;
    for buttonCount, buttonId in ipairs( bindingData.buttons )&lt;br /&gt;
    do&lt;br /&gt;
        local deviceId = bindingData.deviceId&lt;br /&gt;
&lt;br /&gt;
        -- Modifiers are always on the keyboard, so force the device id&lt;br /&gt;
        -- on anything before the final button, so we can show things like shift-mouse3&lt;br /&gt;
        if( numButtons ~= buttonCount )&lt;br /&gt;
        then&lt;br /&gt;
            deviceId = SystemData.InputDevice.KEYBOARD&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        local buttonName = GetButtonName( deviceId, buttonId )&lt;br /&gt;
        ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[API:GetButtonName|GetButtonName]]&lt;br /&gt;
* [[API:GetActionsForButtonCombination|GetActionsForButtonCombination]]&lt;br /&gt;
* [[API:GetActionIdFromName|GetActionIdFromName]]&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>