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.move_mouse(dx, dy)-Relative mouse movement in pixels
input.snap_to(player, bone, [proj_speed])-Snap crosshair onto a target's bone in one call. Internally runs targeting.compute_aim_delta and applies the result as a mouse move

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 with one call:

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.