Script not detecting Left Control key

Hello there! I am creating a GUI that detects a user’s input for a controls list.

I am having an issue wherein my script does not detect Enum.KeyCode.LeftControl.

The odd thing here is that the same exact script works for other keycodes, except for the left control key. I have tried adding in a print function when the keyis pressed, but the script still doesn’t seem to detect the key.

Here is my LeftCtrl script:

local UIS = game:GetService("UserInputService")
local imageid = script.Parent.Image

UIS.InputBegan:Connect(function(input, processed)
    if (input.KeyCode == Enum.KeyCode.LeftControl and processed == false) then
		script.Parent.Image = "rbxgameasset://Images/long key pressed (1)"
    end
end)

UIS.InputEnded:Connect(function(input, processed)
    if (input.KeyCode == Enum.KeyCode.LeftControl and processed == false) then
		script.Parent.Image = imageid
    end
end)

Here is the exact same script with a different keycode:

local UIS = game:GetService("UserInputService")
local imageid = script.Parent.Image

UIS.InputBegan:Connect(function(input, processed)
    if (input.KeyCode == Enum.KeyCode.LeftShift and processed == false) then
		script.Parent.Image = "rbxgameasset://Images/long key pressed (1)"
    end
end)

UIS.InputEnded:Connect(function(input, processed)
    if (input.KeyCode == Enum.KeyCode.LeftShift and processed == false) then
		script.Parent.Image = imageid
    end
end)

And here is a video of the output:
devforum1

If I could get some help here, that would be much appreciated!

Hope this helps:

But try to switch to the ContextActionService and you can debug with printing.

1 Like

Unfortunately, swapping over to ContextActionService did not do anything.

In my game, I swapped the mouse lock control from LeftShift over to LeftControl. Does this affect anything?

I managed to solve this issue by going back to UIS and getting the Keycode number in a similar script.

Thanks for replying though!

1 Like

Keycode number? Can you pls show the new script? I never understod these numbers…

It’s the same script as the one I posted, except the script checks for keycode numbers.

Here’s a page on keycode numbers.

1 Like