GetCommandsBoundToKey: Difference between revisions
Jump to navigation
Jump to search
m (Correction) |
(Loss 'both' state) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 13: | Line 13: | ||
**'''"up":''' If the bound key should trigger the function when the key is released | **'''"up":''' If the bound key should trigger the function when the key is released | ||
**'''"down":''' If the bound key should trigger the function when the key is pressed | **'''"down":''' If the bound key should trigger the function when the key is pressed | ||
**'''"both":''' If the bound key should trigger the function when the key is pressed or released | |||
===Returns=== | ===Returns=== | ||
Returns a table of the commands bound on that key. | Returns a table of the commands bound on that key. | ||
==Example== | ==Example== | ||
<section name="Client" class="client" show="true"> | |||
This example adds the command /keycommands <theKey> <keyState> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | addCommandHandler ( "keycommands", | ||
function ( commandName, theKey, keyState ) | |||
if ( theKey and keyState ) then -- We check if theKey and keyState is valid. | |||
local commands = getCommandsBoundToKey ( theKey, keyState ) | |||
if ( commands and type ( commands ) == "table" ) then | |||
for command, state in pairs ( commands ) do | |||
outputChatBox ( command ) | |||
end | |||
end | |||
else | |||
outputChatBox ( commandName ..": Correct syntax: [ theKey ] [ keyState ]" ) | |||
end | |||
end | |||
) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{ | {{Client_input_functions}} | ||
Latest revision as of 15:12, 20 July 2018
Gets the commands bound to a key.
Syntax
table getCommandsBoundToKey ( string theKey, string keyState )
Required Arguments
- theKey: See key names for a list of possible keys
- keyState: A string that has one of the following values:
- "up": If the bound key should trigger the function when the key is released
- "down": If the bound key should trigger the function when the key is pressed
- "both": If the bound key should trigger the function when the key is pressed or released
Returns
Returns a table of the commands bound on that key.
Example
Click to collapse [-]
ClientThis example adds the command /keycommands <theKey> <keyState>
addCommandHandler ( "keycommands", function ( commandName, theKey, keyState ) if ( theKey and keyState ) then -- We check if theKey and keyState is valid. local commands = getCommandsBoundToKey ( theKey, keyState ) if ( commands and type ( commands ) == "table" ) then for command, state in pairs ( commands ) do outputChatBox ( command ) end end else outputChatBox ( commandName ..": Correct syntax: [ theKey ] [ keyState ]" ) end end )
See Also
- getAnalogControlState
- getBoundKeys
- getCommandsBoundToKey
- getKeyBoundToCommand
- getKeyState
- isCapsLockEnabled
- setAnalogControlState
- Shared
- addCommandHandler
- bindKey
- executeCommandHandler
- getCommandHandlers
- getFunctionsBoundToKey
- getKeyBoundToFunction
- isControlEnabled
- removeCommandHandler
- toggleAllControls
- toggleControl
- unbindKey