Input API

The Input API provides full access to mouse, keyboard, and scroll states from AngelScript. All functions are safe — no pointers or raw memory are exposed to scripts.


📍 Mouse

Get Mouse Position

void get_mouse_pos(float &out x, float &out y)

Returns the current mouse position within the viewport.


Get Mouse Position Relative To Desktop

void get_mouse_pos_desktop(float &out x, float &out y)

Returns the absolute mouse position in desktop coordinates (OS-space).


Get Mouse Movement Delta

void get_mouse_delta(float &out dx, float &out dy)

Returns the delta movement of the mouse since the last frame (viewport space).


Get Mouse Movement Delta Relative To Desktop

void get_mouse_delta_desktop(float &out dx, float &out dy)

Returns the desktop-space delta of mouse movement since the last frame.


Was Mouse Movement Received

Returns true if any mouse movement has been received during this frame.


Get Scroll Delta

Returns the scroll wheel delta value for the current frame.


Is Hovered Over Region

Returns true if the mouse is hovering over a given rectangular region.

  • (x, y) — Top-left corner of the region.

  • (w, h) — Width and height of the region.


⌨️ Keyboard

Keyboard functions use virtual key (VK) codes (standard Windows-style, e.g., 0x41 = A).


Key State Queries

Each of the following functions takes an int vk (the virtual key code):

Function
Description

key_down

Returns true if the key is currently held down.

key_raw_down

Returns raw (unfiltered) down state.

key_fired

Returns true if the key transitioned from up→down this frame (WinProc like input for input boxes, etc).

key_toggle

Returns toggle state (for keys like CapsLock).

key_singlepress

True only once per press event (useful for UI).

key_prev_down

Returns true if the key was down in the previous frame.


Get Key State

Fetches all key state flags at once for the specified key.


Get Keys Down

Fills an array with the virtual key codes of all keys currently held down.

Example:


🔡 Text Input

Get Latest Key Input

Returns a string containing the most recently typed characters since the last frame. Use this for text fields or console input.


Get Key Name By VK

Returns a human-readable name for the specified virtual key code. Example: get_key_name(0x41)"A"


🧠 Notes

  • All keyboard queries use the Windows-style VK codes (0x01 = LMB, 0x41 = A, 0x1B = ESC, etc.).

  • Mouse functions operate in viewport space unless the “desktop” variant is used.

  • Functions are designed to be safe and lightweight — they only read internal copies of state.

  • You can safely call any of these from UI, game logic, or render scripts.


🧩 Example Usage


Version

Last updated