Bind keymap:Keymap key:Str := action:Any...

Assign keys. This command arranges that action is invoked when the key is pressed while keymap is active. keymap is an identifier or ByName() expression. The key is a string specifying the key, the action is either a string containing a command, or a numeric atom (see Atom, Key).

For example,

  Bind PlanetScreen "a" := "AutoBuild"

makes the A key on the planet screen run the AutoBuild command. New key definitions override old definitions.

You can define multiple keys in the same keymap in one line, by simply writing multiple assignments separated by commas.

Keystrokes consist of zero or more modifiers (Ctrl-, Alt-, Shift-, Meta-, possibly abbreviated to C-, A-, etc.), followed by a key name. A key name is either an ASCII character, or a special key name: F1 to F15, Backspace/BS, Pause, Del, Down, End, ESC, Home, Ins, Left, Num5, PgDn, PgUp, Print, Ret/Enter, Right, Space/Spc, Tab, Up, or WheelUp/WheelDown for mouse wheel events. In addition, Quit means the "close-me" button on the window frame ([X]). The available combinations differ between PCC versions and operating systems.

To undefine a key, bind it to the empty string. Unlike object properties, keymaps do not survive PCC exiting and re-loading.

The commands you bind to keys can examine the UI.Prefix variable to find out the current prefix argument.

Unlike PCC 1.x, PCC2 is case-sensitive. When you bind Shift-A, you must actually type an upper-case A to trigger this function (i.e. press ShiftA). PCC 1.x didn't distinguish between upper and lower case for (latin) alphabetic keys. Otherwise, PCC2 ignores the Shift modifier for printable keys. Shift4 generates a "$" sign, so you have to bind $, not Shift-4, if you want something to happen on Shift4. When in doubt, use the keymap debugger.

Since: PCC 1.0.12, PCC2 1.99.9

See also: Elementary Commands