Skip to main content

Inputs

Keycodes

Click -> keycode
SecondaryClick -> keycode
DoubleClick -> keycode
TertiaryClick -> keycode
Tap -> keycode
DoubleTap -> keycode
ArrowUp -> keycode
ArrowLeft -> keycode
ArrowRight -> keycode
ArrowDown -> keycode
Digit0 -> keycode
Digit1 -> keycode
Digit2 -> keycode
Digit3 -> keycode
Digit4 -> keycode
Digit5 -> keycode
Digit6 -> keycode
Digit7 -> keycode
Digit8 -> keycode
Digit9 -> keycode
KeyA -> keycode
KeyB -> keycode
KeyC -> keycode
KeyD -> keycode
KeyE -> keycode
KeyF -> keycode
KeyG -> keycode
KeyH -> keycode
KeyI -> keycode
KeyJ -> keycode
KeyK -> keycode
KeyL -> keycode
KeyM -> keycode
KeyN -> keycode
KeyO -> keycode
KeyP -> keycode
KeyQ -> keycode
KeyR -> keycode
KeyS -> keycode
KeyT -> keycode
KeyU -> keycode
KeyV -> keycode
KeyW -> keycode
KeyX -> keycode
KeyY -> keycode
KeyZ -> keycode
F1 -> keycode
F2 -> keycode
F3 -> keycode
F4 -> keycode
F5 -> keycode
F6 -> keycode
F7 -> keycode
F8 -> keycode
F9 -> keycode
F10 -> keycode
F11 -> keycode
F12 -> keycode
KeySpacebar -> keycode
KeySemicolon -> keycode
KeyQuote -> keycode
KeyBackquote -> keycode
KeyBackslash -> keycode
KeyComma -> keycode
KeyPeriod -> keycode
KeySlash -> keycode
KeyMinus -> keycode
KeyEqual -> keycode
KeyBackspace -> keycode
KeyDelete -> keycode
KeyBracketLeft -> keycode
KeyBracketRight -> keycode
GamepadA -> keycode
GamepadB -> keycode
GamepadX -> keycode
GamepadY -> keycode
GamepadL1 -> keycode
GamepadL2 -> keycode
GamepadL3 -> keycode
GamepadR1 -> keycode
GamepadR2 -> keycode
GamepadR3 -> keycode
GamepadSelect -> keycode
GamepadStart -> keycode
GamepadHome -> keycode

Keycode constants represent all the keyboard, mouse or touchscreen buttons that can be pressed.

ButtonDown

owner.ButtonDown([keycode])

Simulates a player pressing a button.

  • owner (Entity): the player who pressed the button.
  • keycode (Keycode): the button that was pressed.
await owner.ButtonDown([keycode])

Waits for a player to press a button.

  • owner (Entity): the player who pressed the button.
  • keycode (Keycode): the button that was pressed.

ButtonRemap

this.ButtonRemap<Id = auto>(fromKeycode, toKeycode, audience?=, [owner?])
delete this.ButtonRemap<Id>

Causes a keyboard/mouse button to be remapped to another button for a given audience. Whenever fromKeycode is pressed, toKeycode will be triggered instead.

  • this (Entity): The owner of this behavior. When this despawns, the remapping behavior will stop.
  • fromKeycode (Keycode or Array of Keycodes): They keycode that must be pressed to trigger the remapping. Multiple keycodes may be provided in an Array.
  • toKeycode (Keycode): The keycode that will be fired instead of fromKeycode.
  • audience (Entity): If set to a player or team entity, the remapping will only apply to that player or team. Otherwise, all players will be affected. By default, the remapping applies to the owner.
  • owner (Entity): Used as the default value for audience.

ButtonUp

owner.ButtonUp([keycode])

Simulates a player releasing a button.

  • owner (Entity): the player who released the button.
  • keycode (Keycode): the button that was released.
await owner.ButtonUp([keycode])

Waits for a player to release a button.

  • owner (Entity): the player who released the button.
  • keycode (Keycode): the button that was released.

IsGamepadConnected

owner.IsGamepadConnected -> boolean

Returns whether the given owner player has a Gamepad connected.

await owner.IsGamepadConnected -> boolean

Waits for Gamepad connected status to change for the given owner player and returns the new status.

owner.IsGamepadConnected = boolean

Sets the Gamepad connected status for the given owner player. This can be used to simulate input for a bot player.

IsPointerActive

owner.IsPointerActive -> boolean
owner.IsPointerActive = boolean
await owner.IsPointerActive -> boolean

Returns whether the owner player's pointer is currently active. For a mouse, this means whether the mouse is within the borders of the game window or not. For a touchscreen, this means whether the player is currently touching the screen or not.

The property can be set directly to simulate input, which can be used to program a bot player. It is also possible to await this property to wait until it changes.

If owner is nullish or refers to a entity that is not a player, returns undefined.

Joystick

owner.Joystick -> vector
owner.Joystick2 -> vector

Returns the last known position of the owner player's joystick. The x and y components of the Joystick position will fall between -1 and 1.

await owner.Joystick -> vector
await owner.Joystick2 -> vector

Waits for the owner player's joystick to change and then returns the new position.

owner.Joystick = vector
owner.Joystick2 = vector

Sets the owner player's joystick to the given position. This can be used to simulate joystick input for a bot player.

KeyBindingDisplay

KeyBindingDisplay([keycode, ui=])

Adds an element to the user interface that displays the key a player should press to trigger a particular keycode, considering any active key remappings.

  • keycode (Keycode): the keycode of the keyboard key to display.
  • ui (UI): the slot in the user interface where the element will be inserted.

KeyRebindingBlock

KeyRebindingBlock([keycode], backgroundColor?=, color?, expand?, fontSize?, height?, 
opacity?, reveal?, shadow?, stretch?, tooltip?, width?, [ui])

Adds an element to the user interface that allows the player to rebind one keyboard key to another one. The element will display the default key, and the user can click on it to change it. Rebindings are handled transparently by the engine and so no additional code is required to support rebindings besides adding this element to your game.

  • keycode (Keycode): the keycode of the keyboard key to rebind.

  • expand (Boolean or Number): If set, expands the element to fill the remaining space of its container. The remaining space will be divided according to the expand value of all elements in the container. A value of true is equivalent to 1.

  • stretch (Boolean): If true, will expand to fill the full cross-axis of its container. That is, if inside a VStack, will expand to full width, whereas if inside an HStack, will expand to full height.

  • height (Number): the height of the block.

  • width (Number): the width of the block.

  • backgroundColor (Color): the background color of the element.

  • color (Color): the text color of the element.

  • fontSize (Number): The size of the text, measured in em units.

  • opacity (Number): the opacity of the element, from 0 (transparent) to 1 (opaque).

  • reveal (Boolean): If true, the element will be hidden until the mouse hovers over its panel. If the player is not using a mouse, the element will always be visible.

  • shadow (Number): the opacity of the drop shadow, from 0 (no shadow) to 1 (opaque shadow).

  • tooltip (String): the text to display when the mouse hovers over the element, or when it is waiting for the player to input a new key to rebind to.

  • ui (UI): the slot in the user interface where the element will be inserted.

KeyboardVirtualJoystick

this.KeyboardVirtualJoystick(up=, down, left, right, priority?, audience?, [owner?])
this.KeyboardVirtualJoystick2(up=, down, left, right, priority?, audience?, [owner?])

Makes the game simulate a virtual joystick for players that are using the keyboard.

  • this (Entity): defines the lifespan of this behavior. When this despawns, the virtual mouse pointer behavior will stop.

  • audience (Entity): if set to a player or team Entity, the behavior will only apply to those players, rather than all players in the game. If undefined, defaults to the value of owner.

  • owner (Entity): only used as a default value for audience.

  • priority (Number): if the same player has multiple KeyboardVirtualJoystick behaviors, only the one with the highest priority will be active. Must be an integer between -128 and 127 (inclusive). Defaults to 0.

  • left (Keycode or Array of Keycodes): Which keys to use for moving the joystick left.

  • right (Keycode or Array of Keycodes): Which keys to use for moving the joystick right.

  • up (Keycode or Array of Keycodes): Which keys to use for moving the joystick up.

  • down (Keycode or Array of Keycodes): Which keys to use for moving the joystick down.

See Keycodes for a full list of available Keycodes.

delete this.KeyboardVirtualJoystick
delete this.KeyboardVirtualJoystick2

Deletes any previously-added keyboard virtual joystick behavior from this entity.

Pointer

owner.Pointer -> vector
owner.Pointer = vector
await owner.Pointer -> vector

Returns the last known position of the owner player's pointer. For a mouse, this is the last known position of the mouse cursor. For a touchscreen, this is the last touched position, unless the TouchscreenVirtualPointer behavior applies to the player.

The property can be set directly to simulate input, which can be used to program a bot player. It is also possible to await this property to wait until it changes.

If owner is nullish or refers to a entity that is not a player, returns undefined.

TouchscreenMode

owner.TouchscreenMode -> bool

Returns true if the player is using a touchscreen, false otherwise. This is determined by whether the player's first interaction was by touching the screen (as opposed to clicking the mouse). If the player has not interacted yet, this engine will return its best guess, however its value may change once the player interacts. This property will only ever change at most once per player. The only way to enter the game fn is by interacting with a button, and so the touchscreen mode should always be confirmed when inside a game fn.

await owner.TouchscreenMode -> bool

Waits until the player's touchscreen mode changes, then returns the new mode.

TouchscreenVirtualPointer

this.TouchscreenVirtualPointer(audience?=, priority?, [body?, owner?])

Makes the game simulate a virtual mouse pointer for any touchscreen players. Any touches to the screen will be translated to relative movements of a virtual mouse pointer.

  • this (Entity): defines the lifespan of this behavior. When this despawns, the virtual mouse pointer behavior will stop.
  • audience (Entity): if set to a player or team Entity, the behavior will only apply to those players, rather than all players in the game. If undefined, defaults to the value of owner.
  • owner (Entity): only used as a default value for audience.
  • priority (Number): if the same player has multiple TouchscreenVirtualPointer behaviors, only the one with the highest priority will be active. Must be an integer between -128 and 127 (inclusive). Defaults to 0.
  • body (Entity): if set, the virtual mouse pointer will move with this body. This could be set to the hero unit that the player is controlling, for example. This may make it easier to control.
delete this.TouchscreenVirtualPointer

Deletes any previously-assigned TouchscreenVirtualPointer behavior from this entity.