key

Let's you check if keys are pressed etc.

Methods

key.isPressed(keyCode)

  • keyCode - The code of the key

Returns true if given key is pressed.

Example:

-- Turns around 180 degree if pressing A key
if (key.isPressed(0x41)) then
    local view = player.getView()
    view.y = view.y + 180
    player.setView(view)
end

key.isDown(keyCode)

  • keyCode - The code of the key

Returns true if given key is down right now.

Example:

-- Prints while you hold down D key
while (key.isDown(0x44)) do
    print("D key is being held")
end

Last updated