Make your game react to the player. You'll set up named actions like “move_left” once, so they work with any key or controller, then use them to drive your Godot logo around the screen.
Godot can ask two different questions about a button: “Is it held down right now?” and “Was it pressed this exact frame?” Watch both answers over time.
The words you'll see in Godot.
Like jump or move_left. Your code asks about actions, never about specific keys.
The A key, the ← arrow, a controller's left stick. One action can have many events, so A and ← can both mean move_left.
A tab in Project Settings that lists every action and its events. Changing controls later means editing this list, not your code.
is_action_pressed is true every frame while held (good for running). is_action_just_pressed is true for one frame when pressed (good for jumping). is_action_just_released is true for one frame when let go.
Input.get_vector("move_left", "move_right", "move_up", "move_down") combines four actions into one direction, like (1, 0) for right or (0, -1) for up. Diagonals come out the same speed as straight lines.This works just like Godot's Input Map. Practice here, and the real one will feel familiar.
Click + on an action's row, then press the key you want for it. Each + adds one key, so click it again for a second key. Action names use lowercase and underscores, exactly like they'll appear in code.
About 12 minutes. Open your project from Basics 3.
| Action name | Keys |
|---|---|
| move_left | A and ← (done) |
| move_right | D and → |
| move_up | W and ↑ |
| move_down | S and ↓ |
| spin | Space (just one key; don't skip this one!) |
is_action_just_pressed to is_action_pressed, save and run. Hold Space and watch the logo spin out of control, a quarter turn every frame. Then change it back. That's the difference from step 1, in your own game.The name in your code and the name in the Input Map don't match exactly. Check for typos, capital letters and spaces: it must be move_left, all lowercase with an underscore.
Click inside the game window first so it receives your key presses. Also check you pressed F6 with the main tab open, and that Icon has a scroll icon next to it in the Scene dock.
The spin action is probably missing. Open Project → Project Settings → Input Map, add an action called spin, click its + and press Space. Then save and run again.
The action is collapsed. Click the small ▸ arrow to the left of the action's name to expand it. Each key shows underneath with “(Physical)” after it, which is normal.
That action is missing its second event. Go back to Project → Project Settings → Input Map and click + on that action's row to add the missing key.
The order inside get_vector matters: left, right, up, down. Check your line matches the code above.
It's a tab along the top of the Project Settings window, next to General, not a setting inside General. Open it via the Project menu at the top left of the editor.
That's expected! There are no walls yet. Collisions come in Basics 5.
The Godot logo glides smoothly with both WASD and the arrow keys, moves at the same speed diagonally, and turns a quarter turn each time you tap Space. Your coins are still spinning in the background.
Make your logo move at double speed while the player holds Shift, and normal speed when they let go.
You'll need: a new action in the Input Map, the right one of the three “pressed” questions, and a small if.
Start in the Input Map: add an action called sprint with Shift. Then think back to step 1: should running use pressed (every frame while held) or just_pressed (one frame)?
Make a new variable inside _process, like var current_speed := speed. If Input.is_action_pressed("sprint"), set it to speed * 2. Then use current_speed in the movement line instead of speed.
func _process(delta: float) -> void:
var direction := Input.get_vector("move_left", "move_right", "move_up", "move_down")
# Hold Shift to go twice as fast
var current_speed := speed
if Input.is_action_pressed("sprint"):
current_speed = speed * 2
position += direction * current_speed * delta
if Input.is_action_just_pressed("spin"):
rotation_degrees += 90Don't forget the Input Map: Project → Project Settings → Input Map → add sprint → + → press Shift.
Three questions, then you're done.
You can set up actions with several keys each, read them with pressed, just_pressed and get_vector, and you know which question to ask for which kind of control.