getCommandsBoundToKey | Multi Theft Auto: Wiki Skip to content

getCommandsBoundToKey

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


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

  • table: value

Returns a table of the commands bound on that key.

Code Examples

shared

This example adds the command /keycommands

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
)