API GetBindingKey

From Wowpedia
Jump to: navigation, search

Returns all keys currently bound to the command specified by command. This function is almost identical to GetBinding(index) except it takes the command name as an argument instead of the index and doesn't return the command name along with the key bindings.

key1, key2 = GetBindingKey(command)

Arguments

command 
The name of the command to get key bindings for (e.g. MOVEFORWARD, TOGGLEFRIENDSTAB)

Returns

key1-N 
(string) The string representation(s) of all the key(s) bound to this command (e.g. W, CTRL-F)

Example

local command, key1, key2 = GetBinding("MOVEFORWARD")
DEFAULT_CHAT_FRAME:AddMessage(BINDING_NAME_MOVEFORWARD .. " has the following keys bound:")
if key1 then
     DEFAULT_CHAT_FRAME:AddMessage(key1)
end
if key2 then
     DEFAULT_CHAT_FRAME:AddMessage(key2)
end

Notes

Even though the default Key Binding window only shows up to two bindings for each command, it is actually possible to bind more using SetBinding, and this function will return all of the keys bound to the given command, not just the first two.

See also