saving bool to playerprefs as int

I have been able to save ammo, health, score to playerprefs and retrieve it upon “load game” but the final hurdle is trying to save a player inventory item “hasKey” I know it’s a bool where the other attributes are int, but I can’t even get player prefs to set it as an int. in the script, I am trying to say that if the bool hasKey is true, then setint in playerprefs = 1. Thne to see if it worked is the line where savedKey should =1 by Getint. I’ll worry about converting that value of 1 into something I can use but first I need to get it to save and load. I am just perplexed about this. I am following the same pattern I did for setting and getting ints for health, ammo and score

using UnityEngine;
    using System.Collections;
    public class PlayerInventory : MonoBehaviour
    {
    	public bool hasKey;
        public  int keyToSave = 1;
    	public  int savedKey;
    
    	void UpDate(){
    		savedKey =  PlayerPrefs.GetInt("haveKeys");
    	              if (hasKey == true)
    			PlayerPrefs.SetInt("haveKeys", keyToSave);
    	        }
    }

how about Update instead of UpDate

Thanks…I did try that as well in one of my many attempts, but that would surely explain why this version didn’t work. There were all sorts of other issues. I am using C# but the Pause/save/load menu is JS so there’s that whole thing of accessing variables. I could NOT get the PlayerInventory.hasKey to respond to the PlayerPrefs.GetInt. Even when I didn’t mispell Update. Using the exact same code to set the bool hasKey to true when I picked up the key I would get errors when I tried to set it to true using player prefs. Anyway…I decided to just scrap the whole PlayerInventory.hasKey bool and simply set that if I picked up the key hasKeyValue = 50 ( int), then save that int to PlayerPrefs and upon getting the playerprefs had code saying if haskeyValue > 49 then the key image shows up in my GUI as well as changed the door code to accommodate that value saying if haskeyValue > 49 then I could open the door. The number 50 just came about over several attempts and i would change that number to something different each time so I could tell if the new attempt was working. SO when #50 worked I just left it