Hi devs,
I’m wondering if it’s possible to activate UserInputService.InputBegan
while holding down the control / alt key.
Is this a thing?
Edit: I know you can use + CTRL, but I’m not looking for that.
Edit 2: I also know I can use shift.
Hi devs,
I’m wondering if it’s possible to activate UserInputService.InputBegan
while holding down the control / alt key.
Is this a thing?
Edit: I know you can use + CTRL, but I’m not looking for that.
Edit 2: I also know I can use shift.
yes you can use the IsKeyDown
function on UserInputService
UserInputService:IsKeyDown(Enum.KeyCode.LeftControl) -- returns true if the left ctrl is holding
like this
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(Input, GPE)
if UserInputService:IsKeyDown(Enum.KeyCode.LeftControl) and Input.KeyCode == Enum.KeyCode.R then
print("Ctrl + R")
end
end)
Sorry for setting your post as the solution before it actually was, but InputBegan
doesn’t fire while CTRL is being pressed.
I haven’t checked this out of Roblox Studio yet, though.
Try using InputChanged
instead of InputBegan
local Game = game
local UserInputService = Game:GetService("UserInputService")
local function OnInputBegan(InputObject)
if InputObject.KeyCode.Name == "Q" then
if UserInputService:IsKeyDown("LeftControl") or UserInputService:IsKeyDown("RightControl") then
print("Hello world!")
end
end
end
UserInputService.InputBegan:Connect(OnInputBegan)
This works for me. It likely didn’t work before because you were using the ‘GameProcessed’ parameter to ignore inputs handled by the engine.