In my experience, I use this function to handle some features appropriately depending on what inputs the user has available:
function MobileController.IsOnMobile()
return UserInputService.TouchEnabled and (not UserInputService.KeyboardEnabled) and (not UserInputService.MouseEnabled)
end
I understand there’s no actual way of detecting the device or OS of a user, but this function is necessary for prompting the user for the appropriate input for some of our systems. For example, you wouldn’t want to ask a user to click their mouse if UserInputService.MouseEnabled is false.
The problem comes from KeyboardEnabled and MouseEnabled being turned on when an Android user presses Backspace on an empty TextBox, for example the chatbox. The video below demonstrates this happening. Note how KeyboardEnabled and MouseEnabled are false before the bug is reproduced, and how there are PERMANENTLY enabled after closing the keyboard. This only happens when you press backspace on an empty TextBox on an Android device.
Reproduction file:
AndroidBugRepro.rbxl (56.4 KB)
This RBXL features a TextLabel in the middle of the screen that displays the statuses of TouchEnabled, KeyboardEnabled, and MouseEnabled. When pressing Backspace on an empty TextBox on a mobile Android device, you will see that KeyboardEnabled and MouseEnabled turn on.
Expected behavior
On iOS this enabling of KeyboardEnabled and MouseEnabled does not happen when you press backspace on an empty TextBox. This is the intended behavior. The user should not suddenly have a mouse or keyboard plugged in by pressing Backspace in an empty TextBox (and it doesn’t get disabled after typing either).