Update key index correctly.