Hello, good morning, I hope you are all well, I would like to know if you can help me with something I want to do, which is to change the key to open the chat “/” by the enter key. I have seen that in many games the keys to open the chat change, so I would like to implement this in my game, if you know how I can do it, I really appreciate the help.
[SEE BELOW FOR 2024 UPDATE]
The default chat does not have any configuration options for the developers, so there is no direct way of doing it. However, the chat gui is just another gui; it gets parented to PlayerGui and it is comprised of normal gui elements; therefore, we can use a “hacky” method to bind another key.
Using UserInputService and the CaptureFocus function of the text boxes, we can bind more keys. (It is important to note that the chat will still be able to be opened by the “/” key) I’ve prepared an example for you, which will enable the chatbox once you press “Enter” on your keyboard.
The following should go in a local script, and be placed under “StarterGui”:
local UIS = game:GetService("UserInputService")
local Chat = script.Parent:WaitForChild("Chat", 60) --Hacky solutions always ask for long directions ;)
local Box = Chat:WaitForChild("Frame"):WaitForChild("ChatBarParentFrame"):WaitForChild("Frame"):WaitForChild("BoxFrame"):WaitForChild("Frame"):WaitForChild("ChatBar")
UIS.InputBegan:Connect(function(Key, GP)
if not GP and Key.KeyCode == Enum.KeyCode.Return then
Box:CaptureFocus()
end
end)
Important note: A minor update on the chat may cause this system to break. I recommend frequent maintenance, if possible.
SIDE EFFECT: This will also allow the users to send utterly empty messages to the chat! This happens only for the “Enter” key, so I suggest using another one.
[2024 UPDATE]
Roblox entirely changed the core gui behaviour, so this method has been obsolete for a while now. They made it extremely easy by adding new configurations to TextChatService. By changing the KeyboardKeyCode property of ChatInputBarConfiguration, we can now very easily achieve this.
Thanks it works perfect for me!!
This doesn’t work anymore, any other ideas?
Anyone have a new solution to this? Return though can be set will not wont work.
local TextChatService = game.TextChatService
local ChatInputBarConfiguration = TextChatService:WaitForChild("ChatInputBarConfiguration")
ChatInputBarConfiguration.KeyboardKeyCode = Enum.KeyCode.Z
This works but it will not work with Enum.KeyCode.Return
Edit: After almost a year of no progress I opened a bug report