Inputs

Keyboard Inputs client-side

TIP

  • Must be used inside update loop
  • Uses javascript keycodes: https://keycode.info/

WARNING

GAME.INPUTS.keyDown seems to be broken currently

# Do something when "c" (key code 67) is held down
public action update(num delta) {
    if (GAME.INPUTS.keyDown(67)) {
        # do something
    };
}
1
2
3
4
5
6

Mouse Position client-side

WARNING

GAME.INPUTS.mousePos() does not work currently

# Get mouse position
obj mousePosition = GAME.INPUTS.mousePos();

# Draw a red circle at the position of the mouse
GAME.OVERLAY.drawCircle((num) mousePosition.x, (num) mousePosition.y, 10, 10, 0, "#ff0000");
1
2
3
4
5

Mouse Movement client-side

# Get mouse movement vector
obj pos = GAME.INPUTS.mouseMovement();
1
2

Unlock Mouse client-side

# Unlock mouse
GAME.INPUTS.unlockMouse();

# Unlock mouse entirely, unfocussing the window
GAME.INPUTS.freeMouse();
1
2
3
4
5

Input Listeners client-side

# Mouse click
public action onMouseClick(num button, num x, num y) {
    # num button    - mouse click button id (1: left mouse, 2: middle mouse, 3: right mouse, 4+: mouse macro's)
    # num x         - x position of mouse
    # num y         - y position of mouse
}
1
2
3
4
5
6
# After mouse click
public action onMouseUp(num button, num x, num y) {
    # num button    - mouse click button id (1: left mouse, 2: middle mouse, 3: right mouse, 4+: mouse macro's)
    # num x         - x position of mouse
    # num y         - y position of mouse
}
1
2
3
4
5
6
# When mouse scrolls
public action onMouseScroll(num dir) {
	# num dir       - 1: scroll up, scroll left 2: scroll down, scroll right
}
1
2
3
4
# When key is being pressed
public action onKeyPress(str key, num code) {
    # str key        - key in text format. (space == " ")
    # num code       - code of key. (space == 32)
}
1
2
3
4
5
# After key was pressed
public action onKeyUp(str key, num code) {
    # str key        - key in text format. (space == " ")
    # num code       - code of key. (space == 32)
}
1
2
3
4
5
# When key is held
public action onKeyHeld(str key, num code) {
    # str key        - key in text format. (space == " ")
    # num code       - code of key. (space == 32)
}
1
2
3
4
5

Controller input listeners client-side

WARNING

  • Input hooks have a very inconsistent code parameter, its recommended to use the key parameter instead
# Runs when a controller button gets pressed
public action onControllerPress(str key, num code) {
    #str key                - button in text format (dpad up == "dpad_up") 
    #num code               - code of button (shoulder_bottom_left == 10003)
}
1
2
3
4
5
# Runs when a controller button was pressed
public action onControllerUp(str key, num code) {
    #str key                - button in text format (dpad up == "dpad_up") 
    #num code               - code of button (shoulder_bottom_left == 10003) 
}
1
2
3
4
5
# Runs when a controller button is being held
public action onControllerHeld(str key, num code) {
    #str key                - button in text format (dpad up == "dpad_up") 
    #num code               - code of button (shoulder_bottom_left == 10003) 
}
1
2
3
4
5