actionKeys: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (template:command argument fix)
m (Fix SQF)
 
(53 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma |= Game name
|game1= ofpe
|version1= 1.00


|1.00|= Game version
|game2= arma1
____________________________________________________________________________________________
|version2= 1.00


| Returns [[Array]] containing [[DIK_KeyCodes|dikCodes]] of keys, buttons and combos assigned to the given user action. Action names could be found in config class ControllerSchemes or [[:Category:Key Actions|user action names]] or user profile, for example:
|game3= arma2
<syntaxhighlight lang=cpp>
|version3= 1.00
keyWatch[]={24};
 
|game4= arma2oa
|version4= 1.50
 
|game5= tkoh
|version5= 1.00
 
|game6= arma3
|version6= 0.50
 
|gr1= Interaction
 
|descr= Returns [[Array]] containing [[DIK_KeyCodes|dikCodes]] of keys, buttons and combos assigned to the given user action. Action names could be found in config class ControllerSchemes or [[:Category:Key Actions|user action names]] or user profile, for example:
<syntaxhighlight lang="cpp">
keyWatch[] = { 24 };
</syntaxhighlight>
</syntaxhighlight>
To retrieve the value, use the property name without 'key':
To retrieve the value, use the property name without 'key':
<code>[[actionKeys]] "Watch"; // 24</code>
<sqf>actionKeys "Watch"; // 24</sqf>
In addition, some of the actions are also listed in here: [[inputAction/actions]]|DESCRIPTION=
In addition, some of the actions are also listed in here: [[inputAction/actions]]
____________________________________________________________________________________________


| '''actionKeys''' userAction |SYNTAX=
|s1= [[actionKeys]] userAction


|p1= userAction: [[String]] |PARAMETER1=
|p1= userAction: [[String]]


| [[Array]] of [[Number]]s|RETURNVALUE=
|r1= [[Array]] of [[Number]]s
____________________________________________________________________________________________
 
|x1= <code>_array = [[actionKeys]] "ReloadMagazine"</code> |EXAMPLE1=
____________________________________________________________________________________________


| [[actionKeysNames]], [[actionKeysNamesArray]], [[actionKeysImages]], [[actionName]], [[inputAction]] |SEEALSO=
|s2= [[actionKeys]] [userAction]
|s2since=Arma3 2.08


}}
|p21= userAction: [[String]]


<h3 style="display:none">Notes</h3>
|r2= [[Array]] of [[String]]s
<dl class="command_description">
<!-- Note Section BEGIN -->


<!-- Note Section END -->
|x1= <sqf>_arrayOfNumbers = actionKeys "ReloadMagazine";</sqf>
</dl>
|x2= From {{arma3}} v2.08: <sqf>_arrayOfStrings = actionKeys ["ReloadMagazine"];</sqf>


<h3 style="display:none">Bottom Section</h3>
|seealso= [[actionKeysNames]] [[actionKeysNamesArray]] [[actionKeysImages]] [[actionName]] [[inputAction]] [[addUserActionEventHandler]]
}}


[[Category:Scripting Commands|ACTIONKEYS]]
{{Note
[[Category:Scripting Commands OFP Elite |ACTIONKEYS]]
|user= AgentRev
[[Category:Scripting Commands ArmA|ACTIONKEYS]]
|timestamp= 20160511023600
[[Category:Command_Group:_Interaction|{{uc:{{PAGENAME}}}}]]
|text= If an action key is configured with a modifier (e.g. "Right Ctrl + M" for "MiniMapToggle"), the DIK code returned by this command has a weird value, equivalent to the following:<br>
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
: Left Ctrl + Key = 486539264 + DIK
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
: Left Shift + Key = 704643072 + DIK
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
: Left Alt + Key = 939524096 + DIK
: Right Ctrl + Key = -1660944384 + DIK
: Right Shift + Key = 905969664 + DIK
: Right Alt + Key = -1207959552 + DIK</sqf>


<!-- CONTINUE Notes -->
This increases the difficulty of accurately comparing key codes to actionKeys in [[User_Interface_Event_Handlers|UI event handlers]]. Those strange numbers are probably due to bit flags being added to the DIK value by the game engine for easier storage in the [[Profile|ArmaProfile]].<br>
<dl class="command_description">
In case of mouse buttons, actionKeys will also return values that are different from those in "MouseButton" UI events:<br>
<dd class="notedate">Posted on May 11, 2016 - 02:36 (UTC)</dd>
: LMB: MouseButton 0 = actionKeys 65536
<dt class="note">[[User:AgentRevolution|AgentRev]]</dt>
: RMB: MouseButton 1 = actionKeys 65665 (65536 + 1 + 128)
<dd class="note">
: MMB: MouseButton 2 = actionKeys 65538 (65536 + 2)
If an action key is configured with a modifier (e.g. "Right Ctrl + M" for "MiniMapToggle"), the DIK code returned by this command has a weird value, equivalent to the following:<br/>
: 4MB: MouseButton 3 = actionKeys 65539 (65536 + 3)
<br/>
: 5MB: MouseButton 4 = actionKeys 65540 (65536 + 4)
Left Ctrl + Key = 486539264 + DIK<br/>
Left Shift + Key = 704643072 + DIK<br/>
Left Alt + Key = 939524096 + DIK<br/>
Right Ctrl + Key = -1660944384 + DIK<br/>
Right Shift + Key = 905969664 + DIK<br/>
Right Alt + Key = -1207959552 + DIK<br/>
<br/>
<s>For example, to detect if actionKeys "NetworkPlayers" contain a match for  "Right Ctrl + P", one must do the following:
<code> if (-1660944359 in actionKeys "NetworkPlayers") then</code>
with -1660944359 being equal to -1660944384 + 25, and 25 being the DIK code for the "P" key.</s><br/>
<br/>
This increases the difficulty of accurately comparing key codes to actionKeys in [[User_Interface_Event_Handlers|UI event handlers]]. Those strange numbers are probably due to bit flags being added to the DIK value by the game engine for easier storage in the ArmaProfile.<br/>
<br/>
In case of mouse buttons, actionKeys will also return values that are different from those in "MouseButton" UI events:<br/>
<br/>
LMB: MouseButton 0 = actionKeys 65536<br/>
RMB: MouseButton 1 = actionKeys 65665 (65536 + 1 + 128)<br/>
MMB: MouseButton 2 = actionKeys 65538 (65536 + 2)<br/>
4MB: MouseButton 3 = actionKeys 65539 (65536 + 3)<br/>
5MB: MouseButton 4 = actionKeys 65540 (65536 + 4)<br/>
<br/>
The values above are valid for a right-handed mouse configuration, and may or may not differ for a left-handed config.
The values above are valid for a right-handed mouse configuration, and may or may not differ for a left-handed config.
</dd>
<br><small>''Note edited by [[User:R3vo|R3vo]] ([[User talk:R3vo|talk]]) 13:04, 19 March 2021 (CET)''</small>
</dl>
}}
<!-- DISCONTINUE Notes -->


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= Commy2
<dd class="notedate">Posted on August 6, 2016 - 12:24 (UTC)</dd>
|timestamp= 20160806122400
<dt class="note">[[User:Commy2|Commy2]]</dt>
|text= '''The values described by {{User|AgentRev}} cannot be compared <u>reliably</u>.''' All numbers in SQF are floats and those are only precise up to 7 digits.<br>
<dd class="note">
<sqf>486539264 + 19 == 486539264 + 20 // returns true</sqf>
The method described by @AgentRev does not work.<br>
The DIK codes for {{hl|LCtrl + R}} and {{hl|LCtrl + T}} are indistinguishable.
All numbers in SQF are floats and those are only precise up to 6...7 digits.<br>
<br><small>''Note edited by [[User:R3vo|R3vo]] ([[User talk:R3vo|talk]]) 13:04, 19 March 2021 (CET)''</small>
<code>486539264 + 19 == 486539264 + 20
}}
-> true
</code>
The DIK codes for 'LCtrl + R' and 'LCtrl + T' are indistinguishable.
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 18:06, 1 November 2022

Hover & click on the images for description

Description

Description:
Returns Array containing dikCodes of keys, buttons and combos assigned to the given user action. Action names could be found in config class ControllerSchemes or user action names or user profile, for example:
keyWatch[] = { 24 };

To retrieve the value, use the property name without 'key':

actionKeys "Watch"; // 24

In addition, some of the actions are also listed in here: inputAction/actions
Groups:
Interaction

Syntax

Syntax:
actionKeys userAction
Parameters:
userAction: String
Return Value:
Array of Numbers

Alternative Syntax

Syntax:
actionKeys [userAction]
Parameters:
userAction: String
Return Value:
Array of Strings

Examples

Example 1:
_arrayOfNumbers = actionKeys "ReloadMagazine";
Example 2:
From Arma 3 v2.08:
_arrayOfStrings = actionKeys ["ReloadMagazine"];

Additional Information

See also:
actionKeysNames actionKeysNamesArray actionKeysImages actionName inputAction addUserActionEventHandler

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
AgentRev - c
Posted on May 11, 2016 - 02:36 (UTC)
If an action key is configured with a modifier (e.g. "Right Ctrl + M" for "MiniMapToggle"), the DIK code returned by this command has a weird value, equivalent to the following:
Left Ctrl + Key = 486539264 + DIK
Left Shift + Key = 704643072 + DIK
Left Alt + Key = 939524096 + DIK
Right Ctrl + Key = -1660944384 + DIK
Right Shift + Key = 905969664 + DIK
Right Alt + Key = -1207959552 + DIK</sqf>
This increases the difficulty of accurately comparing key codes to actionKeys in UI event handlers. Those strange numbers are probably due to bit flags being added to the DIK value by the game engine for easier storage in the ArmaProfile.
In case of mouse buttons, actionKeys will also return values that are different from those in "MouseButton" UI events:
LMB: MouseButton 0 = actionKeys 65536
RMB: MouseButton 1 = actionKeys 65665 (65536 + 1 + 128)
MMB: MouseButton 2 = actionKeys 65538 (65536 + 2)
4MB: MouseButton 3 = actionKeys 65539 (65536 + 3)
5MB: MouseButton 4 = actionKeys 65540 (65536 + 4)
The values above are valid for a right-handed mouse configuration, and may or may not differ for a left-handed config.
Note edited by R3vo (talk) 13:04, 19 March 2021 (CET)
Commy2 - c
Posted on Aug 06, 2016 - 12:24 (UTC)
The values described by AgentRev cannot be compared reliably. All numbers in SQF are floats and those are only precise up to 7 digits.
486539264 + 19 == 486539264 + 20 // returns true
The DIK codes for LCtrl + R and LCtrl + T are indistinguishable.
Note edited by R3vo (talk) 13:04, 19 March 2021 (CET)