Skip to content

key

The key namespace allows rebinding of standard game actions to different keys. It is based on actions (named intents like Potion or Left) and keys (physical key names from Unity's KeyCode enum).

Binding changes persist between runs but do not save to storage. For performance, avoid rebinding every frame.

Default action bindings

ActionDefault KeyDefault Key 2
PausePSpace
LeaveL
InventoryI
MindstoneM
PotionQ
ItemLeftE
ItemRightR
UpWUpArrow
DownSDownArrow
LeftALeftArrow
RightDRightArrow
PrimaryReturnKeypadEnter
BackX
Ability1LeftShiftRightShift
Ability2LeftControlRightControl
BumpLZ
BumpRC
Dynamic1F
Dynamic2T
Dynamic3G
Dynamic4V
Dynamic5B

key.Bind(act, key1) / key.Bind(act, key1, key2)

Returns: nothing

Assigns up to two keys to an action. If either key is already bound to a different action, it is released from that action.

stonescript
?loc.begin
  key.Bind("Potion", "P")
// "P" now activates Potion instead of Pause.
// The original "Q" key is unbound.

key.GetKeyAct(key) → string

Returns the action currently bound to a given key. Returns "None" if the key is not bound.

key.GetActKey(act) → string

Returns the first key bound to a given action. Returns "None" if no key is bound.

key.GetActKey2(act) → string

Returns the second key bound to a given action. Returns "None" if there is no secondary key.

key.GetActLabel(act) → string

Returns a short user-facing label for the first key bound to an action (currently the first letter of the key name).

key.ResetBinds()

Returns: nothing

Resets all actions to their default key bindings.

Example — swap Potion and Pause keys

stonescript
?loc.begin
  key.Bind("Pause",  "Q")
  key.Bind("Potion", "P")

See also

Stonescript is part of Stone Story RPG.