So i was trying to do a key combination, but, for some reasson, LeftControl isnt detected by IsKeyDown() method.
I tried using different methods to obtain the keys, such as Enum.KeyCode, Enum.KeyCode:FromValue, and Enum.KeyCode:FromName.
Code:
UserInputService.InputBegan:Connect(function(input,gameProcessed)
if input.KeyCode == Enum.KeyCode.Z then
if UserInputService:IsKeyDown(Enum.KeyCode:FromName("LeftControl")) or UserInputService:IsKeyDown(Enum.KeyCode:FromName("RightControl")) then
--Any code i place here will not work.
end
end
end)
Try that the other way around.. Youâll have to press Z first however.
--LocalScript in StarterPlayerScripts
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.LeftControl or
input.KeyCode == Enum.KeyCode.RightControl then
if UserInputService:IsKeyDown(Enum.KeyCode.Z) then
print("Z + Ctrl detected")
end
end
end)
Maybe try a different keybind to test in studio. And try testing ctrl+z in the roblox player to see if studio is the issue. I tested the code and printed all keys being pressed and z never shows up after you press ctrl. ctrl x would work.
hello! there is a very useful method on InputObjects, called IsModifierKeydown(), it takes 1 enum, an Enum.ModifierKey, and CTRL is one of the keys in that enum.
youâd simply do:
if input:IsModifierKeyDown(Enum.ModifierKey.Ctrl)
iâm not sure if it detects both of the Ctrl keys or not.
they probably are :), i just wanted to share a little shortcut iâve discovered a while back.
EDIT: on another note, there is a setting in Studio called âRespect studio shortcuts when game has focusâ, youâd tick that off, and it will not sink any keys bound to studio shortcuts whilst you are testing
Thing is, the engine doesnât fire when regular key is pressed after pressing CTRL and holding it, so IsModifierKeyDown is useless here, itâs likely an engine bug
Even the solution here ^ does no longer work, im positive itâs an engine bug, consider creating bug report
or it could be the case @Razor_IB said, which is still weird cause z + ctrl works, but not ctrl + z