Input
GAMEPAD ALPHA · GAMEPAD BUTTON · GAMEPAD DPAD · GAMEPAD MAP · GAMEPAD OFF · GAMEPAD ON · GAMEPAD PHYSICAL OFF · GAMEPAD PHYSICAL ON · GAMEPAD RESET · GAMEPAD SETIMAGE · PAUSE · RUMBLE · dragx · dragy · inkey · input · isconsole · ismobile · joyaxis · joybutton · joyconnected · keydown · mousedown · mousewheel · mousewheelx · mousex · mousey · tap · touchx · touchy
GAMEPAD ALPHA
The on-screen gamepad’s opacity, 0 to 1.
GAMEPAD ALPHA alpha
gamepad_alpha(alpha)
Parameters
- alpha AS NUMBER - Opacity, 0-1.
Example
SCREEN 320, 240
GAMEPAD ON
GAMEPAD ALPHA 0.4
PRINT "a faint gamepad over the game"
Notes
It’s also the function gamepad_alpha, for when you want what it gives back.
GAMEPAD BUTTON
Show or hide one on-screen gamepad button, or move it (at).
GAMEPAD BUTTON button [, enabled]
gamepad_button(button [, enabled])
Also documents: at
Parameters
- button AS STRING - The button.
- enabled AS BOOLEAN = NULL - Yes shows it, no hides it.
After !!
- at(value AS COORDINATE) - Move it to
(x, y), 0-1 across the screen.
Examples
// A puzzle game uses only the D-pad and A.
SCREEN 320, 240
FOR button = ["B", "X", "Y", "START"]
GAMEPAD BUTTON button, FALSE
END FOR
GAMEPAD ON
SCREEN 320, 240
GAMEPAD ON
GAMEPAD BUTTON "A" !! at((0.85, 0.8))
Notes
It’s also the function gamepad_button, for when you want what it gives back.
GAMEPAD DPAD
How the on-screen D-pad reads touch: “joystick”, “buttons” or “drag”.
GAMEPAD DPAD mode
gamepad_dpad(mode)
Parameters
- mode AS STRING - “joystick”, “buttons” or “drag”.
Example
SCREEN 320, 240
GAMEPAD ON
GAMEPAD DPAD "joystick"
PRINT "the D-pad is an analog stick"
Notes
It’s also the function gamepad_dpad, for when you want what it gives back.
GAMEPAD MAP
Map a gamepad button to the key it presses.
GAMEPAD MAP button, key
gamepad_map(button, key)
Parameters
- button AS STRING - The button: “A”, “UP”, “START”, …
- key AS STRING - The key it presses.
Example
SCREEN 320, 240
IF ismobile()
GAMEPAD ON
ELSE
GAMEPAD PHYSICAL ON
END IF
GAMEPAD MAP "UP", "W"
GAMEPAD MAP "DOWN", "S"
GAMEPAD MAP "LEFT", "A"
GAMEPAD MAP "RIGHT", "D"
GAMEPAD MAP "A", "Space"
PRINT keydown("Space")
Notes
It’s also the function gamepad_map, for when you want what it gives back.
GAMEPAD OFF
Hide the on-screen gamepad.
GAMEPAD OFF
gamepad_off()
Example
SCREEN 320, 240
GAMEPAD ON
// ...a cutscene starts:
GAMEPAD OFF
PRINT "the on-screen gamepad is hidden"
Notes
It’s also the function gamepad_off, for when you want what it gives back.
GAMEPAD ON
Show the on-screen gamepad (touch devices).
GAMEPAD ON
gamepad_on()
Example
SCREEN 320, 240
GAMEPAD ON
GAMEPAD MAP "A", "Space"
PRINT "the on-screen gamepad is up; A presses Space"
Notes
It’s also the function gamepad_on, for when you want what it gives back.
GAMEPAD PHYSICAL OFF
Stop reading physical gamepads.
GAMEPAD PHYSICAL OFF
gamepad_physical_off()
Example
SCREEN 320, 240
GAMEPAD PHYSICAL ON
// ...the player chose keyboard only:
GAMEPAD PHYSICAL OFF
PRINT joyconnected()
Notes
It’s also the function gamepad_physical_off, for when you want what it gives back.
GAMEPAD PHYSICAL ON
Deliver a physical gamepad’s buttons as keys, as the on-screen one does.
GAMEPAD PHYSICAL ON
gamepad_physical_on()
Example
SCREEN 320, 240
GAMEPAD PHYSICAL ON
GAMEPAD MAP "A", "Space"
PRINT joyconnected(), "controllers connected"
Notes
It’s also the function gamepad_physical_on, for when you want what it gives back.
GAMEPAD RESET
Clear every button mapping made with gamepad_map.
GAMEPAD RESET
gamepad_reset()
Example
SCREEN 320, 240
GAMEPAD MAP "A", "Z"
GAMEPAD MAP "B", "X"
GAMEPAD RESET
PRINT "every button back to its own key"
Notes
It’s also the function gamepad_reset, for when you want what it gives back.
GAMEPAD SETIMAGE
Draw an on-screen gamepad button with a loaded image.
GAMEPAD SETIMAGE button, image
gamepad_setimage(button, image)
Parameters
- button AS STRING - The button.
- image AS STRING - A loaded image.
Example
SCREEN 320, 240
LOADIMG "hero.png", "hero"
GAMEPAD ON
GAMEPAD SETIMAGE "A", "hero"
Notes
It’s also the function gamepad_setimage, for when you want what it gives back.
PAUSE
Wait for a key to be pressed.
PAUSE
pause()
Example
SCREEN 320, 240
FUNCTION title_screen()
CLS
PRINT "Press any key"
PAUSE
END FUNCTION
// Called when the game shows its title.
PRINT "title screen ready"
Notes
It’s also the function pause, for when you want what it gives back.
RUMBLE
Rumble the gamepad: both motors (strength), or each (low, high), for duration ms; stop stops it.
RUMBLE [strength, low, high, duration, player, stop]
rumble([strength, low, high, duration, player, stop])
Also documents: duration, high, low, player, stop, strength
Parameters
- strength AS NUMBER = NULL
- low AS NUMBER = NULL
- high AS NUMBER = NULL
- duration AS NUMBER = NULL
- player AS NUMBER = NULL
- stop AS BOOLEAN = NULL
After !!
- duration(value AS NUMBER) - How long, in milliseconds.
- high(value AS NUMBER) - The high-frequency motor, 0-1.
- low(value AS NUMBER) - The low-frequency motor, 0-1.
- player(value AS NUMBER) - Which gamepad.
- stop(on = TRUE) - Yes stops the rumbling.
- strength(value AS NUMBER) - Both motors, 0-1.
Examples
SCREEN 320, 240
GAMEPAD PHYSICAL ON
RUMBLE !! strength(0.8) duration(150)
SCREEN 320, 240
GAMEPAD PHYSICAL ON
RUMBLE !! low(0.9) high(0.2) duration(500) player(1)
RUMBLE !! stop player(1)
Notes
It’s also the function rumble, for when you want what it gives back.
dragx
Returns normalized horizontal drag value from -1 to 1 while actively dragging, 0 when not dragging. Works with both touch (mobile) and mouse (desktop). -1 is maximum left drag, 0 is no drag, 1 is maximum right drag. Values are normalized based on half the screen width. Automatically returns 0 when pointer is released.
dragx
Example
SCREEN 320, 240
x = 160
x = x + dragx() * 4
PRINT "steer", dragx(), "ship at", x
dragy
Returns normalized vertical drag value from -1 to 1 while actively dragging, 0 when not dragging. Works with both touch (mobile) and mouse (desktop). -1 is maximum up drag, 0 is no drag, 1 is maximum down drag. Values are normalized based on half the screen height. Automatically returns 0 when pointer is released.
dragy
Example
SCREEN 320, 240
y = 120
y = y + dragy() * 4
PRINT "steer", dragy(), "ship at", y
inkey
Returns the currently held key as a string, respecting case. Pressing ‘a’ returns “a”, pressing Shift+A returns “A”. Returns an empty string when no key is held. The value clears when the key is released. For case-insensitive key checking, use KEYDOWN() instead.
inkey
Example
SCREEN 320, 240
k = inkey
IF k = ""
PRINT "no key held"
ELSE
PRINT "holding", k
END IF
input
Waits for the player to type a line, and gives it. NULL when there is nothing to read.
input
input(prompt AS STRING = NULL, cursor AS STRING = NULL)
Also documents: cursor
Parameters
- prompt AS STRING = NULL - What to show before the cursor.
- cursor AS STRING = NULL
After !!
- cursor(character AS STRING) - The character to show as the cursor.
Example
SCREEN 320, 240
name = INPUT("Your name? ") !! cursor("_")
PRINT "Hello, " + name
isconsole
Returns 1 on a living-room console — tvOS today, with Xbox and Switch as those platforms land — and 0 everywhere else.
isconsole
Example
SCREEN 320, 240
IF isconsole()
PRINT "press A to start"
ELSE
PRINT "press Enter to start"
END IF
ismobile
Returns 1 on a handheld with a touchscreen — the native iOS and Android players, and a phone or tablet browser — and 0 everywhere else: desktop and tvOS. Use it to gate touch-specific UI: an on-screen gamepad, a “tap to continue” prompt, touch control hints.
ismobile
Example
SCREEN 320, 240
IF ismobile()
GAMEPAD ON
PRINT "tap to continue"
ELSE
PRINT "press a key to continue"
END IF
joyaxis
Requires GAMEPAD PHYSICAL ON. Physical controllers are not polled at all until your program enables them, so before that call this reports nothing — no matter what is plugged in or paired. Enable it early, next to SCREEN, rather than lazily when you first want to read a pad. See GAMEPAD for why a late enable is especially easy to get wrong on Apple TV.
joyaxis(axis, player = NULL)
Parameters
- axis - Axis index 0-7: 0/1 left stick, 2/3 right stick, 4/5 d-pad, 6/7 triggers (see description)
- player = NULL - Optional 0-based controller index (0-3). Defaults to 0.
Example
SCREEN 320, 240
GAMEPAD PHYSICAL ON
x = 100
lx = joyaxis(0)
IF abs(lx) > 0.2 THEN x = x + lx * 5
PRINT x, joyaxis(7, 1)
joybutton
Requires GAMEPAD PHYSICAL ON. Physical controllers are not polled at all until your program enables them, so before that call this reports nothing — no matter what is plugged in or paired. Enable it early, next to SCREEN, rather than lazily when you first want to read a pad. See GAMEPAD for why a late enable is especially easy to get wrong on Apple TV.
joybutton(button, player = NULL)
Parameters
- button - Standard button index (0-17, see description).
- player = NULL - Optional 0-based controller index (0-3). Defaults to 0.
Example
SCREEN 320, 240
GAMEPAD PHYSICAL ON
IF joybutton(0) THEN PRINT "A is down"
PRINT joybutton(9, 1)
joyconnected
Requires GAMEPAD PHYSICAL ON. Physical controllers are not polled at all until your program enables them, so before that call this reports nothing — no matter what is plugged in or paired. Enable it early, next to SCREEN, rather than lazily when you first want to read a pad. See GAMEPAD for why a late enable is especially easy to get wrong on Apple TV.
joyconnected
joyconnected(player = NULL)
Parameters
- player = NULL - Optional 0-based controller index (0-3). When omitted, returns the total connected count instead.
Example
SCREEN 320, 240
GAMEPAD PHYSICAL ON
PRINT joyconnected(), "connected"
PRINT joyconnected(0)
keydown
Returns 1 if the specified key is currently pressed, 0 if not. Ideal for real-time game input and smooth character movement.
keydown(key_name)
Parameters
- key_name - String name of key to check (e.g., “SPACE”, “LEFT”, “RIGHT”, “UP”, “DOWN”, “A”, “ESCAPE”)
Examples
SCREEN 320, 240
x = 160
IF keydown("Left") OR keydown("A") THEN x = x - 2
IF keydown("Right") OR keydown("D") THEN x = x + 2
PRINT x
SCREEN 320, 240
// The key is called "Escape": a name that is no key is never down.
PRINT keydown("ESC"), keydown("Escape")
mousedown
Returns 1 if the specified mouse button is currently pressed, 0 if not. Button parameter is optional and defaults to left mouse button.
mousedown
mousedown(button = NULL)
Parameters
- button = NULL - Mouse button number (0=left, 1=middle, 2=right) - optional, defaults to 0
Example
SCREEN 320, 240
IF mousedown() THEN PRINT "left button down"
PRINT mousedown(0), mousedown(2)
mousewheel
Returns how many notches the mouse wheel has turned vertically since the last time it was read: positive up (away from you), negative down, 0 if it has not moved. Reading it takes them, so a second read straight after returns 0 — read it once a frame into a variable and use that.
mousewheel
Example
SCREEN 320, 240
sel = 3
sel = sel - mousewheel()
PRINT "item", sel
mousewheelx
Returns how many notches the mouse wheel has turned sideways since the last time it was read: positive right, negative left, 0 if it has not moved. Reading it takes them, so a second read straight after returns 0 — read it once a frame into a variable and use that.
mousewheelx
Example
SCREEN 320, 240
camx = 0
camx = camx + mousewheelx() * 16
PRINT camx
mousex
Returns the current X coordinate of the mouse cursor relative to the game canvas.
mousex
Example
SCREEN 320, 240
CIRCLE (mousex, mousey), 6, 14
PRINT "pointer at", mousex, mousey
mousey
Returns the current Y coordinate of the mouse cursor relative to the game canvas.
mousey
Example
SCREEN 320, 240
IF mousey < 120
PRINT "the pointer is in the top half"
ELSE
PRINT "the pointer is in the bottom half"
END IF
tap
Returns 1 while pointer/finger is held down (without dragging), 0 when released or when dragging starts. Works with both touch (mobile) and mouse (desktop) input. This is a state, not an event - it remains 1 continuously while tapping, making it easy to detect in game loops.
tap
Example
SCREEN 320, 240
IF tap()
PRINT "tapping at", mousex, mousey
ELSE
PRINT "not tapping"
END IF
touchx
Returns the current X coordinate of an active touch point in logical game coordinates. Returns -1 if there is no active touch (finger is not touching the screen). Unlike MOUSEX(), this only responds to touch input and ignores mouse input, making it useful for distinguishing between mouse and touch events.
touchx
Example
SCREEN 320, 240
x = touchx()
IF x = -1
PRINT "no finger on the screen"
ELSE
PRINT "touch at", x, touchy()
END IF
touchy
Returns the current Y coordinate of an active touch point in logical game coordinates. Returns -1 if there is no active touch (finger is not touching the screen). Unlike MOUSEY(), this only responds to touch input and ignores mouse input.
touchy
Example
SCREEN 320, 240
PRINT touchx(), touchy()