You'll first have to set the new value, before deleting the old one. Like this:
function changeKey(oldKey, newKey) {
localStorage.setItem(newKey, localStorage.getItem(oldKey));
localStorage.removeItem(oldKey);
}
I would suggest that you do not use the localStorage as an array like that though, but instead use a single localStorage item to store your array:
var myArray = [ { a : 1 }, { b : 2 } ];
localStorage.setItem("myArray", JSON.stringify(myArray));
Then whenever you want to manipulate the array, you can do it like this, and the array indexes will update automatically:
var myArray = JSON.parse(localStorage.getItem("myArray")); // Fetching the array
myArray.splice(myIndex, 1); // Removing an item with index 'myIndex';
localStorage.setItem("myArray", JSON.stringify(myArray)); // Storing the changes