Trim key string