UIS:IsKeyDown() returns always false for other keys when player is holding down left control

So I wanted to add a CTRL + Z shortcut, and while doing so I discovered that when you first hold left control, and then press any other key, then that key doesn’t register. But if you instead press Z and then CTRL, then it registers everything. Also, UIS:GetKeysPressed() suffers from the same issue.

Here’s a code that shows this behaviour:

local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")

RunService.Heartbeat:Connect(function() 
	local ctrl = UserInputService:IsKeyDown(Enum.KeyCode.LeftControl)
	local z = UserInputService:IsKeyDown(Enum.KeyCode.Z)

	warn(ctrl, z)
end)

Hi @Gromaniak85 ,

Thanks for reporting that!

With its default settings Studio will always respect shortcuts, i.e. won’t let the game handle them, and ctrl + z happens to be a Studio shortcut. To disable that behavior, go to File -> Studio Settings -> Studio -> Respect Studio shortcuts when game has focus.

Please, let us know if that fixed your issue!

Yup, that was the issue.

Thank you for your help!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.