Checking if Left shift was pressed with Mouse.KeyDown? (VSB)

Hello devs! So I am working on my Void Script Builder script and I need to check if left shift was pressed, and VSB doesn’t support UserInputService, so I need to use Mouse.KeyDown, and that’s the point of this topic.

You should add support for UserInputService. It has many more functions than mouse.
Once support has been added, you can quickly detect whether LeftShift has been pressed by using UserInputService.InputBegan. You can use Enum for keypress detection.

However, if you cannot use UserInputService, you can try finding the key that is detected when Mouse.KeyDown fires.

1 Like

I found a hacky way to achieve this:

local ContextActionService = game:GetService("ContextActionService")
local Players = game:GetService("Players")

local Player = Players.LocalPlayer 
local Mouse = Player:GetMouse() 

--Unbind the mouse lock action
--You can find all the built-in actions by printing(ContextActionService:GetAllBoundActionInfo())
ContextActionService:UnbindAction("MouseLockSwitchAction")

Mouse.KeyDown:Connect(function(button)
	--I found the symbols by printing(...)
	if button == "/" then 
		print("right shift") 
	elseif button == "0" then
		print("left shift")
	end
end)

In order for Mouse.KeyDown to detect shift, you first have to unbind it using ContextActionService(as shown above).

2 Likes

Nice work, @NyrionDev I liked

1 Like

For some reasons when I did if key == "leftshift" then it worked xd

1 Like

mark that as the solution so others know as well

1 Like