Input API

Check keyboard and mouse input state.

Functions

is_key_down()

Check if a key is currently pressed.

local pressed = kinetic.input.is_key_down(vk_code)

Parameters:

  • vk_code (number) - Virtual key code

Common Key Codes:

0x45  -- E key
0x51  -- Q key
0x52  -- R key
0x46  -- F key
0x20  -- Space
0x10  -- Shift
0x11  -- Ctrl
0x12  -- Alt

Example:

if kinetic.input.is_key_down(0x45) then
    print("E key is pressed")
end

is_mouse_down()

Check if a mouse button is pressed.

Parameters:

  • button (number) - 1 = left, 2 = right, 3 = middle

Example:

get_mouse_pos()

Get current mouse position.

Returns: Table with x and y coordinates

Example:

Complete Examples

Key Toggle

Mouse Tracker

Virtual Key Codes Reference

Key
Code
Key
Code

A-Z

0x41-0x5A

0-9

0x30-0x39

F1-F12

0x70-0x7B

Space

0x20

Shift

0x10

Ctrl

0x11

Alt

0x12

Tab

0x09

Enter

0x0D

Esc

0x1B

Full list

Next Steps

  • System API - Core functions

  • Drawing API - Draw based on input

Last updated