InputMap

InputEvent

Built in type, contains basic information

Event ID, device index

Events are received at the OS level and then spread to nodes through the SceneTree

In general, we want specialized child nodes to handle and consume particular events, while their ancestors provide more generalized behavior.

Events v. Polling

func _input(event):
    if event.is_action_pressed("jump"):
        jump()

func _physics_process(delta):
    if Input.is_action_pressed("move_right"):
        # Move as long as the key/button is pressed.
        position.x += speed * delta

Keyboard Events

captured with InputEventKey

can check for modifier combinations using boolean properties on the event

func _input(event):
    if event is InputEventKey and event.pressed:
        if event.scancode == KEY_T:
            if event.shift:
                print("Shift+T was pressed")
            else:
                print("T was pressed")

Mouse Events

captured with InputEventMouse