How to make it detect keys by putting them in a TextBox?

Hi, I have an error with the following script, which should detect when you press any letter and place it in a TextBox. My problem is that I misspelled the script, crashed, and lost the data so I really didn’t know how to put it the right way and hope you help me with that.

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(Input, GameProcessed)
	print(string.upper(Input.KeyCode.Name)) --If you want it all in upper case

You could just use the GetPropertyChangedSignal function for detecting when a Text gets added or removed in the TextBox:


I remember doing this, but it printed “-”, so I had to convert TextBox.Text to a string using tostring. If it prints “-” then you should try converting it to a string.

1 Like


ROBLOX update your darn API References

Well, I don’t think that’s exactly what I’m looking for. Let me explain, the previous script detects any key and puts in print the name of the letter you pressed, either Tab, shift, Numbers or etc. what I want is to do the same but instead of putting it in print, put it in Texbox.Text

Oh I see, well you could probably do this via getting the Local Player’s GUI:

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local TextGui = PlayerGui:WaitForChild("TextGui"):WaitForChild("TextBox")

UIS.InputBegan:Connect(function(Input, Chatted)
    if Chatted then
    TextGui.Text = tostring(Input.KeyCode.Name)
1 Like

You really are a genius, you have always helped me and I thank you!

1 Like

Excuse my ignorance but, it is only activated without clicking the texbox. I wanted it to be activated by clicking the textbox

I don’t think I quite follow, what do you mean by that?

@Jackscarlett what he means is it is activated before he clicks it but he wants it to be activated when he clicks it not before

1 Like

Well, I have already touched on the subject many times in the forum. I am doing a system of changing keys but only the letters of the alphabet worked, and well I am trying to do that but with all the keys. What I mean is that even if you haven’t clicked the textbox, the letter is changed.

Exactly and sorry, I never really explain myself.

Could you use this?

1 Like