Hello, I was just wondering if there is an exclamation point (!) in KeyCode? If so what is its name so I could use it with UserInputService.InputBegan
1 Like
There isn’t but you can use the available KeyCode enumerations to write your own handler.
local userInput = game:GetService("UserInputService")
local run = game:GetService("RunService")
local function inputBegan(startInput, _)
if startInput.KeyCode.Name:match("Shift$") then
local connection1, connection2
connection1 = run.RenderStepped:Connect(function()
if userInput:IsKeyDown(Enum.KeyCode.One) then
print("! key pressed.")
end
end)
local function inputEnded(endInput, _)
if endInput == startInput then
if connection1 then
if connection1.Connected then
connection1:Disconnect()
end
end
if connection2 then
if connection2.Connected then
connection2:Disconnect()
end
end
end
end
connection2 = userInput.InputEnded:Connect(inputEnded)
end
end
userInput.InputBegan:Connect(inputBegan)
4 Likes
Thank you for answering me i’ll find some way to put this in my game