The methods IsKeyDown
and GetKeysPressed
do not seem to track KeyCode enums from gamepads and input objects created by gamepads.The ideal desired behavior is that they should track and return their respective true values/objects.
user input service gamepad bug repro.rbxl (12.4 KB)
The bug from the tests I’ve done and had other completed is 100% reproducible by doing the following:
(if running the test from the attached repro file skip to step 4)
- Open a new place or use an existing open place
- Make and place a LocalScript in a service where it will run
- Set the LocalScripts source to the code snip it shown below
- Press play solo or Start a server with a client
- Press any buttons on a connected gamepad and observe no acknowledgment of the input in the Output window
local userInput = game:GetService("UserInputService")
local testEnums = {
Enum.KeyCode.ButtonA,
Enum.KeyCode.ButtonB,
Enum.KeyCode.ButtonX,
Enum.KeyCode.ButtonY,
Enum.KeyCode.ButtonL1,
Enum.KeyCode.ButtonL2,
Enum.KeyCode.ButtonL3,
Enum.KeyCode.ButtonR1,
Enum.KeyCode.ButtonR2,
Enum.KeyCode.ButtonR3,
Enum.KeyCode.DPadUp,
Enum.KeyCode.DPadDown,
Enum.KeyCode.DPadLeft,
Enum.KeyCode.DPadRight,
Enum.KeyCode.ButtonSelect,
Enum.KeyCode.ButtonStart,
}
while wait() do
print("IsKeyDown() results:")
for _, enum in next, testEnums do
local value = tostring(userInput:IsKeyDown(enum))
local spacing = 15 - #enum.Name
print(enum.Name..string.rep(" ", spacing)..value)
end
print(string.rep("-", 20))
print("GetKeysPressed() results:")
for _, object in next, userInput:GetKeysPressed() do
print(object.KeyCode.Name)
end
print(string.rep("-", 20))
end
I’m unaware of when this started happening, it was only as of this post that I began noticing it. If this is intended behavior then there is a lack of documentation on the wiki stating the aforementioned methods are strictly for keyboard input regardless of keyboard and gamepad inputs being grouped into the same Enum group.