Skip to content

Input ​

Keyboard and mouse helpers. All keys use Windows VK codes; see Types & Constants for the common ones.

FunctionReturnsDescription
input.is_key_held(vk)booleanKey is currently held
input.is_key_pressed(vk)booleanEdge-triggered, true once per press
input.press_key(vk)-Press and immediately release
input.key_down(vk)-Press without releasing
input.key_up(vk)-Release a held key
input.is_mouse_key(vk)booleanTrue if vk corresponds to a mouse button
input.get_cursor_pos()vec2Current cursor screen position in pixels
input.move_mouse(delta, [speed], [detach])booleanRelative mouse movement. delta is a vec2 of pixel counts. speed > 0 enables smoothed movement (default 0 = instant). detach is the detach factor (default 0). Returns true
input.snap_to(player, bone, [proj_speed])-Snap the crosshair to a target bone. Applies ease-out smoothing (fraction = 1−exp(−deltaMs/60), tau=60 ms) to the targeting.compute_aim_delta result via a persistent accumulator (accum_x/y), integer-truncates, clamps output to ±12 counts (MAX_C=12), carries the remainder, and dispatches a MoveMouse action only when dx≠0 or dy≠0. bone accepts a string (bone name), integer (raw skeleton index), or vec3 (explicit world position)

Examples ​

Hold-to-rage style:

lua
function on_tick()
    if input.is_key_held(0x02) then  -- right mouse button
        -- aimbot logic
    end
end

Press an ability through the game's bound key:

lua
local key = slot_to_key(slot.ABILITY_3)
input.press_key(key)

Edge-triggered toggle:

lua
local on = false

function on_tick()
    if input.is_key_pressed(0x70) then  -- F1
        on = not on
        toast(on and "ON" or "OFF")
    end
end

Snap to a target's head:

lua
function on_tick()
    if not input.is_key_held(0x02) then return end  -- hold right mouse
    local target = targeting.find_closest_by_fov(8.0, 30.0)
    if target and target:is_visible() then
        local proj_speed = local_player():get_active_projectile_speed()
        input.snap_to(target, "head", proj_speed)
    end
end

Not affiliated with Valve Corporation.