Plugin Key Detection

Hello Developers,
I’m creating this. It’s a kind of extension for plugins, a file explorer.

I need to detect when user press SHIFT key to know if he is selecting multiple Instances.
I have written this:


-- this is a server script

UserInputService.InputBegan:Connect(function(key)
	print("key pressed")
	if key.KeyCode == Enum.KeyCode.LeftShift then
		ExplorerPlugin.isShiftDown = true
	end
end)

UserInputService.InputEnded:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.LeftShift then
		ExplorerPlugin.isShiftDown = false
	end
end)

but when I press SHIFT or any other key, “key pressed” doesn’t print to the output. But if I close the explorer window, it print!

Thank you in advance for your help

UserInputService only works in LocalScripts

But it works when user is focused on the viewport frame …

this a plugin not a roblox game

1 Like

So how should I do to make it work?

Try adding more print() statements after the if function and check if they print soemhtign
Edit: I just found a post that could help you How do you detect pressing F in Studio plugin? (how do you get a pre-existing Plugin Action?)

hey @Dede_4242 ! thank you for helping me, I just read this:

and also what you send me about plugin actions, but these action doesn’t fire when the user release the key, so I can’t use that :frowning:
I think I have to look for an other solution…
However, thanks for the help

1 Like

Oh, I’m sorry, I didn’t read the whole post as I’m not an expert and I wouldn’t get anything, I’m sorry, hope you are gonna be able to solve your problem

no no problem, you tried to help me ! thank you!

1 Like