ContextActionService button pressed, even when it didn't get pressed?

I’m using BindAction to assign an action to the shift key. It works fine for the most part, but sometimes the action executes on its own, as though I pressed the shift key, even when I know I didn’t.
I’ve tried reproducing it, but it seems random as far as I know. What might be the issue?

Here’s my code:

local player = game.Players.LocalPlayer
local character = game.Workspace:WaitForChild(player.Name)
local deb = false
local item = script.Parent.Parent.Item
local event = game:GetService("ReplicatedStorage"):WaitForChild("ItemUse")
local TweenService = game:GetService("TweenService")
local userInputService = game:GetService("UserInputService")

local tweenInfo =, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)

if userInputService.TouchEnabled then
	script.Parent.Parent.MobileTap.Visible = true

function Execute()
	if deb == false and script.Parent.Parent.Position.Y.Scale < 0.83 then --Make sure the item icon is in-view
		if item.Value == 1 then
			local itemVal = item.Value
			item.Value = 0
			script.Parent.Parent:TweenPosition(,0,1,0), "In", "Quint", 1, true)
			script.Parent.Parent.Background.Forcefield.Visible = false
		if item.Value == 2 then
			local itemVal = item.Value
			item.Value = 0
			game.Players.LocalPlayer.Character.Humanoid.JumpPower = 120 + player.PerkJump.Value
			workspace.Gravity = 200
			script.Parent.Parent:TweenPosition(,0,1,0), "In", "Quint", 1, true)
			script.Parent.Parent.Background.Coil.Visible = false
			game.Players.LocalPlayer.Character.Humanoid.JumpPower = 93 + player.PerkJump.Value
			workspace.Gravity = 240

function onKeyPress(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then

game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.LeftShift, Enum.KeyCode.ButtonX)

In your ‘onKeyPress’ function could you add a ‘print(actionName)’ to see what’s causing it to get pressed?

Sure–when I did this, it always printed “keyPress”.
I DID find out that it could have something to do with the “if item.Value == 2” loop. After the 18 seconds were up, and if you had an item in your inventory, it usually used it, even if you didn’t press anything. But I’m not sure what would have caused that, either.

It may not be the cause of the weird behaviour, but if deb is supposed to be a debounce (which it definitely should be with that 18-second wait in there and remote events to prevent spamming them) then I can’t see where deb is ever set to true.

Perhaps you forgot to add it after checking deb == false.