Skip to content

Io

const io = require("@vectarine/io")
io.isKeyDown(keycode: Scancode | string): boolean

Checks if a key is pressed For example, IsKeyDown("Space"). If the name is invalid, always return false. You can use ‘GetKeysDown’ to find the name of keys

io.getKeyName(keycode: Scancode | string): string

Get the name of a key. For example getKeyName(“Z”) returns “W” on AZERTY but “Z” on QWERTY. This is the name you should show the player when telling them to press a key. Returns nil if the scancode is invalid.

io.getTextInput(): string

Get the text inputed since the last frame. This should be used for typing text, while IsKeyDown should be used for checking if a key is pressed for actions.

io.isKeyJustPressed(keycode: Scancode | string): boolean

Checks if a key was just pressed (this frame) The keys are independent from the keyboard layout, so “Q” is always the top-left letter, even on AZERTY layouts. This is the function you need to map button presses to actions, but not for typing text. For example, IsKeyJustPressed("space"). If the name is invalid, always return false. You can use ‘GetKeysDown’ to find the name of keys

io.getKeysDown(): { Scancode }

Returns a list of key that are currently pressed

io.getMouse(): Vec.Vec2

Get the current mouse position in OpenGL coordinates

io.getMouseState(): {

Get the current mouse state

io.getMouseWheel(): Vec.Vec2

Get how much the mouse wheel has been scrolled since the last frame. The x value is for horizontal scrolling, and the y value is for vertical scrolling. This is because some mice have horizontal scroll (but i’ve never seen one in real life). On most mice, the x value will always be 0.

io.getCurrentTouches(): { Touch }

Get all fingers that are currently touching the screen.

io.getWindowSize(): Vec.Vec2

Get the current window size (in px)

io.centerWindow(): ()

Center the window on the screen Does nothing on the web

io.getScreenSize(): Vec.Vec2

Get the current screen size (in px)

io.setWindowSize(width: number, height: number): ()

Sets the window size. On the web and in the editor, this adds black borders to make the window match the requested aspect ratio. On desktop, this will resize the window to the requested size.

io.setResizeable(resizeable: boolean): ()

Set if the window is resizeable

io.setWindowTitle(title: string): ()

Set the window title

io.isWindowMinimized(): boolean

Returns true if the window is currently minimized When this is the case, Vectarine will run a lot slower to save battery life and avoid draining the CPU.

io.setFullscreen(fullscreen: true | false | "fullscreen" | "windowed" | "desktop"): ()

Set the window to fullscreen, windowed, or “desktop fullscreen” (also called fake fullscreen) mode true means “fullscreen”, false means “windowed”. Before calling this function, you can set the window size to the size of the screen to avoid black borders. On the web, the game is usually embedded in an iframe / player which already provides a fullscreen button, so this function does nothing.

export type Scancode = ...

List of all available scancodes. A scancode is a location on the keyboard, independent of keyboard layout.

export type Touch = ...
id: number

A stable identifier for this finger while it remains on the screen.

position: Vec.Vec2

The current position in OpenGL coordinates.

pressure: number

The normalized pressure reported by the device.