mouse
pykraken.mouse Mouse related functions
At a glance
11 membersReference
PYTHON APIget_pos
functionget_pos() -> Vec2Get the current position of the mouse cursor.
Returns
- Vec2 — The current mouse position as (x, y) coordinates.
get_rel
functionget_rel() -> Vec2Get the relative mouse movement since the last frame.
Returns
- Vec2 — The relative movement of the mouse as (dx, dy).
hide
functionhide() -> NoneHide the mouse cursor from view.
The cursor will be invisible but mouse input will still be tracked.
is_just_pressed
functionis_just_pressed(button: MouseButton) -> boolCheck if a mouse button was pressed this frame.
Args
- button (
MouseButton) — The mouse button to check.
Returns
- bool — True if the button was just pressed.
is_just_released
functionis_just_released(button: MouseButton) -> boolCheck if a mouse button was released this frame.
Args
- button (
MouseButton) — The mouse button to check.
Returns
- bool — True if the button was just released.
is_locked
functionis_locked() -> boolCheck if the mouse is currently locked to the window.
Returns
- bool — True if the mouse is locked.
is_pressed
functionis_pressed(button: MouseButton) -> boolCheck if a mouse button is currently pressed.
Args
- button (
MouseButton) — The mouse button to check (e.g., kn.MOUSE_LEFT).
Returns
- bool — True if the button is currently pressed.
lock
functionlock() -> NoneLock the mouse to the center of the window.
Useful for first-person controls where you want to capture mouse movement without letting the cursor leave the window area.
show
functionshow() -> NoneShow the mouse cursor if it was hidden.
unlock
functionunlock() -> NoneUnlock the mouse from the window, allowing it to move freely.