Sub topic 5
Inserting, updating, and deleting keyframes
This chapter assumes you can move objects in the 3D Viewport, read the Properties editor, and set the current frame as described in the earlier chapters on frames and keyframes. It covers the three operations you use constantly: creating a keyframe, changing one, and removing one. It also covers how Blender's field colors show the state of a property, and the common mistakes.
What an insert actually does
A keyframe stores one property's value at one frame. When you insert a keyframe, Blender reads the property's current value and the scene's current frame. It writes that pair into an F-curve, which is the stored curve for that property. If the object has no action yet, Blender creates one first and assigns it to the object. Every frame between keys is then calculated by interpolation.
Two consequences matter in practice:
- A keyframe belongs to a single property, or to a single component of a vector property. Keying Location keys X, Y, and Z as three separate F-curves.
- The frame you are on when you press the key decides where the key lands. Check the playhead before you insert.
Ways to insert a keyframe
In the 3D Viewport
Select an object, set the frame, position the object, and press I with the cursor over the viewport.
The result depends on your Blender version:
- In Blender 4.1 and later, I keys the channels listed in Preferences > Animation > Keyframes > Default Key Channels. By default these are Location, Rotation, Scale, Rotation Mode, and Custom Properties. K opens a menu where you choose a keying set, which is a named group of properties to key together.
- In Blender 2.8 through 4.0, I opens a menu where you pick what to key, such as Location or Location & Rotation.
In the Properties editor
Hover over any animatable field and press I. Blender keys the whole vector, so hovering over Location Y keys X, Y, and Z. You can also right-click the field and choose:
- Insert Keyframes for all components.
- Insert Single Keyframe for only the component under the cursor.
The diamond icon next to a field does the same thing as I. Clicking it inserts a key, and clicking it again on a keyed frame removes the key.
Through the Timeline
The Timeline has a Keying popover with the active keying set and the Auto Keying toggle. Auto Keying is covered in its own chapter. Manual insertion is the safer habit while you are learning, because it never creates a key you did not ask for.
Reading the field colors
The color of a property field tells you its animation state at the current frame.
| Field color | Meaning |
|---|---|
| Gray | The property has no animation. |
| Green | The property is animated, but there is no key on this frame. The value is interpolated. |
| Yellow | There is a key on this frame, and the value matches it. |
| Orange | The property is animated, but you changed its value and have not keyed it yet. |
Orange is the one to watch. It means the value on screen is not stored anywhere. If you change frames now, Blender re-evaluates the F-curve and your edit disappears.
Updating a keyframe
Blender has no separate "update" command. Inserting a keyframe on a frame that already has one replaces the old value. The workflow is:
- Go to the frame of the key you want to change.
- Change the value with the tool or field. The field turns orange.
- Press I again. The field turns yellow, and the key now stores the new value.
You can also change the value on a different frame, key it there, and then move the key in the Dope Sheet. Moving keys is covered in the chapters on editing and retiming.
If you only want to adjust where a key sits in time, do not re-insert it. Re-inserting leaves the old key in place and adds a second one.
Deleting keyframes
Different deletion tools remove different amounts of animation.
| Action | Where | What it removes |
|---|---|---|
| Alt+I | 3D Viewport | Keys of the selected objects at the current frame, for the channels it would key. |
| Alt+I | Hovering over a field | The key on that property at the current frame. |
| Shift+Alt+I | Hovering over a field | Every key on that property. This is Clear Keyframes. |
| X or Delete | Dope Sheet or Timeline | The selected keys. Blender asks you to confirm in the Dope Sheet. |
| Right-click > Delete Keyframes | Properties field | Same as Alt+I on that property. |
Deleting every key on a property leaves the property with its last value, and the field goes back to gray. The animation is gone but the object does not jump back to its original position. Blender removes the empty F-curve, but the action itself stays assigned to the object.
Doing the same with Python
The keyframe_insert() and keyframe_delete() methods mirror the manual operations. They take the property's data path, an optional component index, and an optional frame.
import bpy
scene = bpy.context.scene
scene.frame_start = 1
scene.frame_end = 48
obj = bpy.context.active_object
# Insert: key the whole location vector at frame 1
obj.location = (0.0, 0.0, 0.0)
obj.keyframe_insert(data_path="location", frame=1)
# Insert: key the whole location vector at frame 24
obj.location = (0.0, 0.0, 2.0)
obj.keyframe_insert(data_path="location", frame=24)
# Update: change the value and key the same frame again
obj.location = (0.0, 0.0, 3.0)
obj.keyframe_insert(data_path="location", frame=24)
# Insert a single component: only Z, with index=2
obj.location.z = 1.0
obj.keyframe_insert(data_path="location", index=2, frame=12)
# Delete: remove the Z key at frame 12
obj.keyframe_delete(data_path="location", index=2, frame=12)The script keys frame 24 twice. The second call replaces the first value instead of adding a duplicate, which matches the behavior of pressing I a second time in the interface. keyframe_delete() raises a RuntimeError if there is no key to remove at that frame, so wrap it in try if you cannot be sure one exists.
Common mistakes
- Wrong frame. Keys land on the current frame, not where you are looking in the Timeline. Check the playhead before pressing I.
- Edits that vanish. An orange field means the edit is unkeyed. Press I before you change frames.
- Keying more than you meant. In Blender 4.1 and later, I in the viewport keys every default channel. If you want only location, use the Properties editor, or change the Default Key Channels preference.
- Partial keys. If you key only Location Z, X and Y stay unanimated. Later edits to X and Y will not stick between frames, because they have no keys.
- Duplicate-looking keys. Re-inserting never creates two keys on the same frame. If you see two diamonds close together, they are on different frames.
Exercise
You are on frame 30 and the object's Location Z field is orange. You press the Right Arrow to go to frame 31 and the object moves back. What happened, and what should you have done?
Show answer
The orange field meant the new Z value was not stored in any keyframe. When you changed frames, Blender re-evaluated the F-curve and replaced your edit with the animated value. You should have pressed I with the cursor over the field (or in the viewport) at frame 30 first, which stores the value and turns the field yellow.
Exercise
A script calls obj.keyframeinsert(datapath="rotationeuler", index=0, frame=10) and then calls it again on the same frame after changing rotationeuler[0]. How many keys exist on the rotation X F-curve at frame 10, and why?
Show answer
One. Inserting a key on a frame that already has a key on that F-curve replaces its value instead of adding another key, the same as pressing I twice in the interface.