How do I keybind a textbox with the enter key?
I'm trying to make a scripting command bar that can be used in game. (To elaborate, a textbox, that when someone enters Lua code into it and pushes enter, that code will run.) I came up with a working version.
Originally, the user would have to click out of the text box and then push enter, due to the fact that I used the KeyUp event of Mouse, and therefore, the event wouldn't fire while the user is focused on the text box. Recently, I discovered an event of text box called InputChanged, which is supposed to detect things like keyboard inputs even when the user is focused on the TextBox. I tried it, but it didn't fire whenever I pushed the enter key. My code, where script.Parent is a TextBox:
1 | script.Parent.InputChanged:connect( function (input) |
2 | local key = input.KeyCode |
3 | if key = = "Return" then |
4 | script.Parent.Update.Value = true |
6 | script.Parent.Update.Value = false |
How would I bind the enter key to the TextBox, even when the user is focused on it. If not this event, then is there another that I should use?