How to make a UI Image appear/disappear?

I want to press the key “I” on the keyboard and have an image appear and after pressing “I” on my keyboard again, the image will disappear.

This might be way more obvious than I think it is, but I’ve looked everywhere for hours and can’t find anything.

C# or Javascript, I’m not picky!

Successfully tested and works (for me) ;))

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class ImageShow : MonoBehaviour {

	public bool isImgOn;
	public Image img;

	void Start () {

		img.enabled = true;
		isImgOn = true;

	void Update () {
		if (Input.GetKeyDown ("i")) {

			if (isImgOn == true) {

				img.enabled = false;
				isImgOn = false;

			else {

				img.enabled = true;
				isImgOn = true;

ı have a canvas with uı object but ı cant enabled and disable them.The are some question in my project.For example first question is true ı want to disable it and enable second one.I am looking for this questions for afew days but i couldnt find it :(((

I’ve tried this solution but it gives me this error:
error CS0723: Cannot declare a variable of static type ‘MediaTypeNames.Image’

This is how my codes looks like:

Do you know how I can fix it?