Hello, i am making a LocalScript that detects if the player has pressed ANY button.
I want it to be any button is that Xbox and Mobile users can also press a button without needing to code extra scripts.
I already know the KeyPressed event. I just want to know how to detect if any key is pressed. Thanks.
You can connect to UserInputService.InputBegan
and then check if KeyCode
isn't Enum.KeyCode.Unknown
like this:
game:GetService("UserInputService").InputBegan:Connect(function(iobj, gp) if gp then return end --if they are typing in a textbox or something if iobj.KeyCode ~= Enum.KeyCode.Unknown then print("a key has been pressed, woooo!") end end)