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

Keyboards Keys ('/')?

Asked by
Tor6 0
10 years ago

I know how to get keys in code. But how do you get the '/' key? I'm making a custom chat gui, and I can't seem to get it to work?

1 answer

Log in to vote
1
Answered by
DataStore 530 Moderation Voter
10 years ago

The slash key doesn't trigger the KeyDown event, but it does trigger the KeyUp event. An example of how to do this is below.

local Mouse = game.Players.LocalPlayer:GetMouse()

Mouse.KeyUp:connect(function(Key)
    if Key == "/" then
        print("The slash key was used")
    end
end)

However, you should really use UserInputService, as using KeyUp means there would be a short delay between when they pressed '/' and when they could type. If you did use UIS, you would use the InputBegan event and read the KeyCode property of the given InputObject.

local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.Slash then
        print("The slash key was pressed")
    end
end)
Ad

Answer this question