# MoveKey(int, Keyframe)

> Moves the key at index to /key.time/ and /key.value/.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public int MoveKey(int index, Keyframe key)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The index of the key to move.**** (\[Keyframe]\(/engine/6000.7/script-reference/unityengine/keyframe)): The keyframe containing the new time and value.

### Returns

| Type                                                       | Description                                  |
| ---------------------------------------------------------- | -------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the keyframe after it is moved. |

### Remarks

This method removes the keyframe at `index` and inserts the updated `key` at the correctly sorted position in [AnimationCurve.keys](/engine/6000.7/script-reference/unityengine/animationcurve/keys.md).

Use this method to move a keyframe in two dimensions: time and value.

To use this method as intended, use [AnimationCurve.keys](/engine/6000.7/script-reference/unityengine/animationcurve/keys.md) to acquire the keyframe, modify the value and/or time, then invoke this method with the updated keyframe. If you use this method with a different keyframe, this method replaces the keyframe with a new one.

AnimationCurve does not support two keys with the same time. If /key.time/ is the same as another keyframe, `key` is reinserted at the time of the keyframe at `index`. This cancels the move operation in the time dimension and keeps the modification in the value dimension.

See Also: [AnimationCurve.keys](/engine/6000.7/script-reference/unityengine/animationcurve/keys.md)
