For the “multiple times” issue, you have to make it so that the piece of code above doesn’t execute again unless the button is released. Otherwise, the player presses the button for several frames and makes it so that the piece of code gets executed multiple times. Look at this script.
When you press the button, the isPressed variable turns into true and the code is executed. However, the script now requires that the button be released in the previous frame. isPressed turns false only if the button is released. This ensures that inventory doesn’t switch every time Update() gets called.