Menu
CoddyTech

Press to Move

Part of the Input and Movement section of Coddy's Godot journey. Lesson 1 of 28.

Godot reads keys through input actions: names for what the player wants to do. Every game in this course has these actions:

  • move_left, move_right, move_up, move_down: the arrow keys and WASD
  • jump: Space, W or Up
  • action: E or Enter

Input.is_action_pressed("move_right") is true while the player holds the right arrow or D. Ask it in _process, which runs every frame:

func _process(delta):
	if Input.is_action_pressed("move_right"):
		position.x += 200 * delta

The line under the if starts with two tabs. It runs only in frames where the key is held, so the hero stops when you let go.

challenge icon

Challenge

Easy

Make the hero walk right at 200 pixels per second while you hold move_right. When you let go, the hero stops.

Try it yourself

extends Node2D

func _process(delta):
	pass
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Input and Movement

Practice on your own: Godot playground