Skip to main content

Input

Contains functions for changing input bindings.

info

This module can only be used in Entity scripts.

Functions​

bind(target, keyCode, callback, inputMode)​

Binds a function to a key.

Parameters​

  • target — Either the target Player, client ID of the target player, or Players.All to target all players.
  • keyCode — The Key to bind.
  • callback — The function to bind. (It runs for a maximum of 1 second.).
  • inputMode — The InputMode which determines when the function is going to be called (optional).

Example​

Bind the function "test" to "T" when the player enters the entity.

function test()
Hud.console.write('hello SuperCoder')
end

function onPlayerEnter(player)
Input.bind(player.clientId, Key.T, test)
end

unbind(target, keyCode, inputMode)​

Unbinds all the functions previously bound to a key.

Parameters​

  • target — Either the target Player, client ID of the target player, or Players.All to target all players.
  • keyCode — The Key to unbind.
  • inputMode — The InputMode to unbind (optional).

Example​

Unbind all the functions bound to "T" when the player exits the entity.

function onPlayerExit(player)
Input.unbind(player.clientId, Key.T)
end

setPlayerActionBinding(target, keyCode, playerAction)​

Sets a key to a player action. This will override the current key set to that specific PlayerAction.

Parameters​

  • target — Either the target Player, client ID of the target player, or Players.All to target all players.
  • keyCode — The Key to bind to the player action.
  • playerAction — The PlayerAction to set.

Example​

Set the player action "Jump" to work with "V" when the player enters an entity.

function onPlayerEnter(player)
Input.setPlayerActionBinding(player.clientId, Key.V, PlayerAction.Jump)
end

setPreset(target, inputPreset)​

Sets the current input preset, which will override all the current player actions with the new InputPreset (You can visualize and modify all the presets in the editor).

Parameters​

  • target — Either the target Player, client ID of the target player, or Players.All to target all players.
  • inputPreset — The Key to bind to the player action.

Example​

Set the input preset to "TwoDimensions" when the player enters an entity.

function onPlayerEnter(player)
Input.setPreset(player.clientId, InputPreset.TwoDimensions)
end

setMoveWithArrowsEnabled(target, isEnabled)​

Set Arrow Keys for movement. Control your character's movement with the arrow keys.

Parameters​

  • target — Either the target Player, client ID of the target player, or Players.All to target all players.
  • isEnabled — Define if a player can move with the arrow keys.

Example​

Disable movement with arrow keys when the player enters an entity.

function onPlayerEnter(player)
Input.setMoveWithArrowsEnabled(player.clientId, false)
end

Enums​

Key​

  • None — value = 0
  • Space — value = 1
  • Enter — value = 2
  • Tab — value = 3
  • Backquote — value = 4
  • Quote — value = 5
  • Semicolon — value = 6
  • Comma — value = 7
  • Period — value = 8
  • Slash — value = 9
  • Backslash — value = 10
  • LeftBracket — value = 11
  • RightBracket — value = 12
  • Minus — value = 13
  • Equals — value = 14
  • A — value = 15
  • B — value = 16
  • C — value = 17
  • D — value = 18
  • E — value = 19
  • F — value = 20
  • G — value = 21
  • H — value = 22
  • I — value = 23
  • J — value = 24
  • K — value = 25
  • L — value = 26
  • M — value = 27
  • N — value = 28
  • O — value = 29
  • P — value = 30
  • Q — value = 31
  • R — value = 32
  • S — value = 33
  • T — value = 34
  • U — value = 35
  • V — value = 36
  • W — value = 37
  • X — value = 38
  • Y — value = 39
  • Z — value = 40
  • Digit1 — value = 41
  • Digit2 — value = 42
  • Digit3 — value = 43
  • Digit4 — value = 44
  • Digit5 — value = 45
  • Digit6 — value = 46
  • Digit7 — value = 47
  • Digit8 — value = 48
  • Digit9 — value = 49
  • Digit0 — value = 50
  • LeftShift — value = 51
  • RightShift — value = 52
  • LeftAlt — value = 53
  • AltGr — value = 54
  • AltGr — value = 54
  • LeftCtrl — value = 55
  • RightCtrl — value = 56
  • LeftWindows — value = 57
  • LeftWindows — value = 57
  • LeftWindows — value = 57
  • LeftWindows — value = 57
  • RightCommand — value = 58
  • RightCommand — value = 58
  • RightCommand — value = 58
  • RightCommand — value = 58
  • ContextMenu — value = 59
  • Escape — value = 60
  • LeftArrow — value = 61
  • RightArrow — value = 62
  • UpArrow — value = 63
  • DownArrow — value = 64
  • Backspace — value = 65
  • PageDown — value = 66
  • PageUp — value = 67
  • Home — value = 68
  • End — value = 69
  • Insert — value = 70
  • Delete — value = 71
  • CapsLock — value = 72
  • NumLock — value = 73
  • PrintScreen — value = 74
  • ScrollLock — value = 75
  • Pause — value = 76
  • NumpadEnter — value = 77
  • NumpadDivide — value = 78
  • NumpadMultiply — value = 79
  • NumpadPlus — value = 80
  • NumpadMinus — value = 81
  • NumpadPeriod — value = 82
  • NumpadEquals — value = 83
  • Numpad0 — value = 84
  • Numpad1 — value = 85
  • Numpad2 — value = 86
  • Numpad3 — value = 87
  • Numpad4 — value = 88
  • Numpad5 — value = 89
  • Numpad6 — value = 90
  • Numpad7 — value = 91
  • Numpad8 — value = 92
  • Numpad9 — value = 93
  • F1 — value = 94
  • F2 — value = 95
  • F3 — value = 96
  • F4 — value = 97
  • F5 — value = 98
  • F6 — value = 99
  • F7 — value = 100
  • F8 — value = 101
  • F9 — value = 102
  • F10 — value = 103
  • F11 — value = 104
  • F12 — value = 105
  • OEM1 — value = 106
  • OEM2 — value = 107
  • OEM3 — value = 108
  • OEM4 — value = 109
  • OEM5 — value = 110
  • IMESelected — value = 111

InputMode​

  • KeyDown — value = 0
  • KeyUp — value = 1

PlayerAction​

  • MoveForward — value = 0
  • MoveBackward — value = 1
  • MoveRight — value = 2
  • MoveLeft — value = 3
  • Jump — value = 4
  • Dash — value = 5
  • Interact — value = 6
  • Mount — value = 7
  • Block — value = 8
  • LockOnTarget — value = 9
  • SwitchTarget — value = 10
  • Flashlight — value = 11

InputPreset​

  • Default — value = 0
  • Platformer2D — value = 1
  • Slot1 — value = 2
  • Slot2 — value = 3
  • Slot3 — value = 4