Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I use KeyDown/KeyUp for Tab?

Asked by
nilVector 812 Moderation Voter
9 years ago

I want to make it to where when you hold the tab key down, a GUI appears, and when you let go of it, it disappears.

I have already disabled the PlayerList coreGUI.

I tried what you would normally do for a KeyDown and KeyUp event for any other key such as "q", and it works, but when I try it with Tab, it doesn't work.

Here's the script (local):

wait()

local sp = script.Parent --the GUI
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

mouse.KeyDown:connect(function(key)
    if key:byte() == 9 then
        sp.Visible = true
    end
end)

mouse.KeyUp:connect(function(key)
    if key:byte() == 9  then
        sp.Visible = false
    end
end)

Alternatively, I have used...

if key == string.char(9) then

...and that does not work either.

When I check for a non-special character like this:

if key:lower() == "q" then

..it works.

How can I make it work for Tab?

Answer this question