BindAction to 5+ keys Cancelled is fired

PC Info: Windows 10, 22H2
Impact: High
Frequency: Often, 1/4 of runs
Date First Experienced: 6/21/2023
Date Last Experienced: 07/04/2023

If you fire BindAction to 5+ keybinds, it will fire Cancelled for the last one

Reproduction Steps:

  1. Create a LocalScript parented to StarterCharacterScripts or StarterPlayerScripts (or download the placefile below)
  2. Add the below code and hit play and try multiple times.
local ContextActionService = game:GetService("ContextActionService")
local keybinds = {
	Enum.KeyCode.Q,
	Enum.KeyCode.F,
	Enum.KeyCode.Y,
	Enum.KeyCode.U,
	Enum.KeyCode.Space,
	
}

for i, v in keybinds do
	ContextActionService:BindAction(
		i,
		function(action, state, input)
			print(action, state, input.KeyCode, input.UserInputType)
		end,
		false,
		v
	)
end

bug_contextactionservice.rbxl (46.2 KB)

Expected Behavior: Should bind the action to the keycode

Actual Behavior:
image

Furthermore, if you bind a duplicate keybind, it completely cancels 100% of the time. Though this could be intentional.

9 Likes

Also encountering this issue.

System information:
Intel(R) Core™ i7-9700K CPU @ 3.60GHz, 3600 Mhz, 8 Core(s), 8 Logical Processor(s)
32GB
NVIDIA GeForce RTX 2070

2 Likes

Any updates on this? Really annoying

Thanks for the report! Just to confirm, we have a ticket for this in our internal database.

2 Likes

Hi,

This happens because Enum.KeyCode.Space is overriding the Enum.PlayerActions.CharacterJump action. That’s why you end up seeing the cancel message being fired.

The number of bindings does not matter. You can repro this by just binding to the Enum.KeyCode.Space key.

The override of the keycode generating a cancel event is intended.

Hey, thanks for the update. Sadly this isn’t correct, if you change the space one to anything it still happens.

local keybinds = {
	Enum.KeyCode.Q,
	Enum.KeyCode.F,
	Enum.KeyCode.Y,
	Enum.KeyCode.U,
	Enum.KeyCode.G,
}

Any update on this? This is causing a hindrance in development

1 Like