_keypressed.md 935 B

This function is called everytime a key is pressed.

When the button is held for a little bit longer, this function will be called multiple times with isrepeat as true.


Important Note: Besure to call Controls("keyboard") in the first line of the game !

Another Note: The keyboard on android can be closed by the user, so to reshow it you should call textinput(true) in _touchpressed callback.


Syntax:

function _keypressed(key,scancode,isrepeat)
  --Do something here
end

Arguments:

  • key (String): The pressed button, check KeyConstants Enum.
  • scancode (String): The scancode representing the pressed key, check check Scancodes Enum.
  • isrepeat (Boolean): Whether this keypress event is a repeat. The delay between key repeats depends on the user's system settings.