public function deleteKey($keyname) {

        $key = $this->getKey($keyname);
        if ($key) {
            $i = $this->findKeyInArray($keyname);
            // Look for prev and next key
            $prevkey = $this->getKey($key->getPrevious());
            $nextkey = $this->getKey($key->getNext());
            // Change their previous and next attributes
            if ($prevkey) {
                $prevkey->setNext($key->getNext());
            }
            if ($nextkey) {
                $nextkey->setPrevious($key->getPrevious());
            }
            // Delete the key
            unset($this->keys[$i]);
            // Reorder the Keys
            $this->orderKeys($this->keys);
            // Recalculate the hash
            $this->calculateHash(true);
            // We have one deleted key, so the table has changed
            $this->setChanged(true);
        }
    }