Whether the key is held right now. key is a virtual key, usually written input.vk.space. The mouse buttons are keys too: input.vk.mouse1 is the left button. Keys held while some other window has the focus are not reported - the script sees input only while the game is in front.
trueonce, on the call that sees the key go down. Each script remembers, per key, what it saw the last time it asked, so the answer depends on the calls this script makes: ask from one place per key. Two handlers that both call input.pressed( input.vk.f5 ) take turns catching the edge.
The cheat's own hotkeys: every setting that has a key bound, in the order they were registered, as { name, category, key, key_name, mode, active } - useful for drawing a list of what is currently bound and which binds are active.
on( "frame", function( canvas )
local y = 200
for _, bind in ipairs( input.hotkeys( ) ) do
if bind.active then
canvas:text( 20, y, bind.name .. " [" .. bind.key_name .. "]", color( 255, 255, 255 ) )
y = y + 16
end
end
end )
Keys are identified by the numbers Windows calls virtual-key codes. input.vk has a name for each one a script is likely to want, so you never need the numbers:
Names
Keys
input.vk.a ... input.vk.z
the letters
input.vk.n0 ... input.vk.n9
the number row
input.vk.f1 ... input.vk.f12
the function keys
input.vk.numpad0 ... input.vk.numpad9
the numeric keypad
mouse1, mouse2, mouse3, mouse4, mouse5
left, right and middle button, and the two side buttons
shift, ctrl, alt
either side; lshift, rshift, lctrl, rctrl, lalt, ralt for one side
end_key is called that because end is a Lua keyword and cannot follow a dot. All the values are plain integers, so input.vk.space == 32, and a key code received in an input message compares directly against them.
on( "input", function( msg )
if msg.kind == "key_down" and msg.key == input.vk.f9 and not msg.repeated then
print( "F9 pressed" )
end
end )