I can’t find any documentation on an event which indicates that a keyboard has been connected/disconnected. How would I check for this with events, instead of constantly polling UserInputService.KeyboardEnabled
? (If there even is a way).
Thanks.
I can’t find any documentation on an event which indicates that a keyboard has been connected/disconnected. How would I check for this with events, instead of constantly polling UserInputService.KeyboardEnabled
? (If there even is a way).
Thanks.
Currently, Roblox does not provide any event for checking if a keyboard has been connected or disconnected specifically. Hopefully, in future Roblox might add this feature to their API but till now we need to deal with existing ones. To circumvent the lack of this functionality, one potential solution is using a while loop that checks KeyboardEnabled state once every few seconds or use a heartbeat to make it less performance intensive. However, be aware that this is not the same as an event-based solution and could have performance issues if not used properly.
local UserInputService = game:GetService("UserInputService")
while wait(1) do
if UserInputService.KeyboardEnabled then
print("Keyboard is connected!")
else
print("Keyboard not detected!")
end
end