✓ Accepted answer
Use UserInputService's GameProcessed parameter. It indicates whether the game engine has internally observed the same InputObject and acted on it. This predominantly refers to UI processing, one of which will activate GameProcessed if typing in the default chat.
To ensure we're recognizing that they're typing in chat, we should filter the input processing for only keyboard InputObjects.
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(InputObject, GameProcessed)
if (InputObject.UserInputType = Enum.UserInputType.Keyboard) then
if (GameProcessed) then
if (InputObject.KeyCode == Enum.KeyCode.Return) then
end
end
end
end)
If you wish to act upon someone typing within a TextBox the code below will produce the same effect!
TextBox.Focused:Connect(function()
print("Someone is typing!")
end)
TextBox.FocusLost:Connect(function(ReturnPressed)
if (ReturnPressed) then
print("Someone stopped typing!")
end
end)
If this helps, don't forget to accept this answer!