Problem with flashlight function

The problem is that when I press the F key, the flashlight flickers a bit.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TankMove : MonoBehaviour
{
//Move Player
public float moveSpeed = 3f;
public float turnSpeed = 100f;
public float nitroSpeed = 5f;

public GameObject Flashlight;

void Awake()
{
     
}

void Update()
{
    if (Input.GetKey(KeyCode.W))
    {
        transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
    }

    else if (Input.GetKey(KeyCode.LeftShift))
    {
        transform.Translate(Vector3.forward * nitroSpeed * Time.deltaTime);
    }

    if (Input.GetKey(KeyCode.S))
    {
        transform.Translate(-Vector3.forward * moveSpeed * Time.deltaTime);
    }

    if (Input.GetKey(KeyCode.A))
    {
        transform.Rotate(Vector3.up, -turnSpeed * Time.deltaTime);
    }

    if (Input.GetKey(KeyCode.D))
    {
        transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime);
    }

    Lamp_key();

}

void Lamp_key()
{
    Light FlashlightComp = Flashlight.GetComponent<Light>();

    if (Input.GetKey(KeyCode.F))
    {
        if (FlashlightComp.enabled)
        {
            FlashlightComp.enabled = false;
        }
        else
        {
            FlashlightComp.enabled = true;
        }

    }
}

}

Hi there @Vladislav_Aleshin, i believe you have to change Input.GetKey(KeyCode.F) to Input.GetKeyDown(KeyCode.F)

Thank you (@Mr_parkour10021 ) and ( @Legend_Bacon ), final code.

public class TankMove : MonoBehaviour

{

//Move Player

[Header("Player")]

public float moveSpeed = 3f;

[Range(0f,100f)]

public float turnSpeed = 100f;

public float nitroSpeed = 5f;

[Header("Car lamp")]
public GameObject FlashlightRight;
public GameObject FlashlightLeft;

public Light FlashlightLeftComp;
public Light FlashlightRightComp;

void Start()
{
    FlashlightLeftComp = FlashlightLeft.GetComponent<Light>();
    FlashlightRightComp = FlashlightRight.GetComponent<Light>();
}

void Update()
{
    if (Input.GetKey(KeyCode.W))
    {
        transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
    }

    else if (Input.GetKey(KeyCode.LeftShift))
    {
        transform.Translate(Vector3.forward * nitroSpeed * Time.deltaTime);
    }

    if (Input.GetKey(KeyCode.S))
    {
        transform.Translate(-Vector3.forward * moveSpeed * Time.deltaTime);
    }

    if (Input.GetKey(KeyCode.A))
    {
        transform.Rotate(Vector3.up, -turnSpeed * Time.deltaTime);
    }

    if (Input.GetKey(KeyCode.D))
    {
        transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime);
    }

    Lamp_key();

}

void Lamp_key()
{
    if (Input.GetKeyDown(KeyCode.F))
    {
        if (FlashlightLeftComp.enabled && FlashlightRightComp.enabled)
        {
            FlashlightLeftComp.enabled = false;
            FlashlightRightComp.enabled = false;
        }
        else
        {
            FlashlightLeftComp.enabled = true;
            FlashlightRightComp.enabled = true;
        }

    }
}

}