Structs:KeyBindings

From ZDoom Wiki
Jump to navigation Jump to search
Note: This feature is for ZScript only.


This struct contains functionality related to key bindings.

Methods

All methods are defined as native, meaning their inner workings are handled in C++.

Static

The keys recognized by these methods are integer values either from the InputEvent struct, or obtained with GetKeysForCommand/GetAllKeysForCommand.

  • static String NameKeys(int k1, int k2)
Returns the names of the two provided keys. This function is essentially deprecated, being superseded by the more efficient NameAllKeys().
  • static String NameAllKeys(array<int> list, bool colors = true)
Returns the names of all keys contained in the provided array. The string is colorized by default, but that can be circumvented by passing false to the colors argument (so that the string can be later colorized with the appropriate string-drawing function arguments or color codes).

Dynamic

Dynamic KeyBindings methods can be called in ZScript on the global Bindings pointer.

The command arguments are what you would type in the console to trigger that action.

  • int, int GetKeysForCommand(String cmd)
Returns the first two keys for the provided command. This function is essentially deprecated, being superseded by the more robust GetAllKeysForCommand.
  • void GetAllKeysForCommand(out array<int> list, String cmd)
Fills the provided array with keys for the provided command.
  • String GetBinding(int key)
Returns the command bound to the provided key as a string.
  • void SetBind(int key, String cmd)
Binds the specified command to the specified key. Can only be called in a UI event from a Menu class.
  • void UnbindACommand(String str)
Unbinds the specified command from a key. Can only be called in a UI event from a Menu class.