input.on_key_pressed method

on_key_pressed(self, handler: Callable[[], None], key_code: KeyCode) -> None:

Triggers every frame while specified KeyCode is pressed.

Note: Only one onKeyPressed handler can be defined for a key at any time.

Parameters

  • handler: Callable[[], None]

    function to call. Pass null to remove the handler.

  • key_code: KeyCode

    key to press.