# Make it impossible to have multiple keyframes on the same frame in the sequencer

**URL:** <https://forums.unrealengine.com/t/make-it-impossible-to-have-multiple-keyframes-on-the-same-frame-in-the-sequencer/692807>\
**Category:** Feedback & Requests\
**Tags:** unreal-engine\
**Created:** [November 17, 2022, 1:22pm UTC](https://forums.unrealengine.com/t/make-it-impossible-to-have-multiple-keyframes-on-the-same-frame-in-the-sequencer/692807 "2022-11-17T13:22:22Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![mugenmelon](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mugenmelon/32/1035828_2.png) [@mugenmelon](https://forums.unrealengine.com/u/mugenmelon)\
**Post date:** [March 16, 2025, 1:35pm UTC](https://forums.unrealengine.com/t/make-it-impossible-to-have-multiple-keyframes-on-the-same-frame-in-the-sequencer/692807/3 "2025-03-16T13:35:26Z")

</div>

I was wrong. The _Reduce keys_ option both in the track section as well as in the CurveEditor only reduce keys based on their _value_ instead of their _time_. So this solution does not work. Turns out there is no built-in way to remove duplicate keys.

So I wrote a small CurveEditorFilter class that seems to do the job.  
**No guarantees that this works flawlessly.**

**CurveEditorTimeReduceFilter.h**

```c++
#pragma once

#include "Filters/CurveEditorFilterBase.h"
#include "CurveEditorTimeReduceFilter.generated.h"

UCLASS(DisplayName="Simplify Time")
class UCurveEditorTimeReduceFilter : public UCurveEditorFilterBase
{
	GENERATED_BODY()

public:
	explicit UCurveEditorTimeReduceFilter();

protected:
	UPROPERTY(EditAnywhere, meta=(Units="s"))
	double Tolerance;

	virtual void ApplyFilter_Impl(TSharedRef<FCurveEditor> InCurveEditor, const TMap<FCurveModelID, FKeyHandleSet>& InKeysToOperateOn, TMap<FCurveModelID, FKeyHandleSet>& OutKeysToSelect) override;
};

```

**CurveEditorTimeReduceFilter.cpp**

```c++
#include "Curve/Filter/CurveEditorTimeReduceFilter.h"

UCurveEditorTimeReduceFilter::UCurveEditorTimeReduceFilter() : Super(), Tolerance(0.01) {}

void UCurveEditorTimeReduceFilter::ApplyFilter_Impl(const TSharedRef<FCurveEditor> InCurveEditor, const TMap<FCurveModelID, FKeyHandleSet>& InKeysToOperateOn, TMap<FCurveModelID, FKeyHandleSet>& OutKeysToSelect)
{
	OutKeysToSelect = InKeysToOperateOn;
	for (const auto& Pair : InKeysToOperateOn)
	{
		const auto CurveId = Pair.Key;
		const auto& KeySet = Pair.Value;
		auto* Curve = InCurveEditor->FindCurve(CurveId);
		if (!Curve || KeySet.Num() <= 1)
		{
			continue;
		}

		const TArray<FKeyHandle> Keys(KeySet.AsArray());
		TArray<FKeyPosition> Positions;
		Positions.SetNum(Keys.Num());
		Curve->GetKeyPositions(Keys, Positions);

		TArray<FKeyHandle> KeysToRemove;
		auto& SelectedKeysInCurve = OutKeysToSelect[CurveId];
		auto LastTime = Positions[0].InputValue;
		for (int32 i = 1; i < Positions.Num(); i++)
		{
			const auto CurrentTime = Positions[i].InputValue;
			if (FMath::IsNearlyEqual(CurrentTime, LastTime, Tolerance))
			{
				KeysToRemove.Add(Keys[i]);
				SelectedKeysInCurve.Remove(Keys[i], ECurvePointType::Key);
			}
			else
			{
				LastTime = CurrentTime;
			}
		}
		if (KeysToRemove.Num() > 0)
		{
			Curve->Modify();
			Curve->RemoveKeys(KeysToRemove);
		}
	}
}

```

Drop these into one of your editor modules and make sure to add a dependency on “CurveEditor” in your build file as well.  
Then select all the keys you want to de-duplicate in the CurveEditor, go to _Filters_ and select the _Simplify Time_ filter. Adjust tolerance as needed and apply.

---

_[View the full topic](https://forums.unrealengine.com/t/make-it-impossible-to-have-multiple-keyframes-on-the-same-frame-in-the-sequencer/692807)._
