Is it possible to make a Button that operates a Computer Key for Mobiles?
For example: If a Mobile button is pressed, it operates the “Q” Key.
All kinds of help will be appreciated.
Is it possible to make a Button that operates a Computer Key for Mobiles?
For example: If a Mobile button is pressed, it operates the “Q” Key.
All kinds of help will be appreciated.
You cannot simulate keys being pressed without VirtualUser (which is only usable in the command bar). To achieve what you want to do, you would need a global function being called whem the Q key is pressed or the button is pressed.
Something like thi scan be achieved using ContextActionService and it’s BindAction method. You can create an action for your computer key, and let it create a button that will act as the key on touch devices.
local ContextActionService = game:GetService("ContextActionService")
local player = game.Players.LocalPlayer
function OnTPressed()
--Do something
end
local createTouchButton = true
ContextActionService:BindAction("TestAction", OnTPressed, createTouchButton, Enum.KeyCode.Q)
Setting the createTouchButton parameter to true will create a GUI button on touch devices. It will basically act like pressing Q in this case.
This is a basic example of this, look into the documentation to learn more.
Thanks, but I do not need the function, I only need it for custom Dialog properties, since it doesn’t function on click or tap, it necessarily requires the “Q” Button.
Hmm, completely simulating a key press probably isn’t possible.
But I imagine that even your custom Dialog system somehow binds the Q key to some function. You could simply bind your GUI button to that same function, no?
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.