How can I tap a key to enter and tap the same key to exit?

What am I trying to do? I’m trying to stop a string.lower to make a tap key to enter and tap the same key again too exit.
I can’t figure out how to do it because for Mouse.KeyDown there isn’t an option for that can someone help me?

EDIT: I have solved this by using Key:byte()

Look into using a debounce.

for an example, something along the lines of

db = false
mouse = game.Players.LocalPlayer:GetMouse()

mouse.KeyDown:connect(function(key)
    if key:lower() == "g" then
        if db == false then
            db = true
            --code for enter
        else
            db = false
            --code for exit
        end
    end
end)