Skip to main content

GetAnyKeyPressed

This function was added in DSL 1

Description

Returns any keyId that would satisfy IsKeyPressed.

function GetAnyKeyPressed() --[[ ... ]] end

Parameters

None.

Return Values

  • keyId: integer? - The ID of the key that is currently pressed. nil if no key is pressed.

Versions

  • DSL4 - DirectInput keyboard scan codes are now used, but virtual key code names will still be converted for legacy support.
  • DSL5 - Keys are also reported as pressed when they are being pressed, and no longer when they are being released.

Example

function main()
while true do
local key = GetAnyKeyPressed()
if key then
DrawTextInline('Key ID ' .. tostring(key) .. ' is currently pressed!', 0, 1)
end
Wait(0)
end
end

See Also