Skip to content

API Mouse and keyboard

Alexandre 'kidev' Poumaroux edited this page Oct 21, 2026 · 4 revisions

Mouse and keyboard

Import from proleak import input

Mouse and keyboard hooks. Handlers observe; they cannot block the game's own input.

Functions

Returns Function
Callable click(fn: Handler | None = None, button: int = 0) Call fn(ev) on mouse clicks (button: 0 left, 1 right).
Handler hover(fn: Handler) Call fn(ev) when the cursor moves onto a unit (ev.unit).
Callable key(name: str, fn: Handler | None = None, shift: bool = False, ctrl: bool = False, alt: bool = False) Call fn(ev) when key name (a Unity KeyCode name such as "F" or "F5") is pressed with exactly these modifiers.

Function documentation

click

click(fn: Handler | None = None, button: int = 0) -> Callable

Call fn(ev) on mouse clicks (button: 0 left, 1 right). ev has screen and world positions and ev.unit, a Unit (None when no unit is under the cursor).

hover

hover(fn: Handler) -> Handler

Call fn(ev) when the cursor moves onto a unit (ev.unit).

key

key(name: str, fn: Handler | None = None, shift: bool = False, ctrl: bool = False, alt: bool = False) -> Callable

Call fn(ev) when key name (a Unity KeyCode name such as "F" or "F5") is pressed with exactly these modifiers.


Previous: Logging | Next: Player actions

Clone this wiki locally