How to detect keyboard presses when focused on a TextBox

Exactly what the title says, I need to detect keyboard presses for TextBoxes. This is different when detected when text changes, because it doesn’t give me exactly what the user typed (for example, Ctrl+V pastes text, so the text change is whatever I pasted, but keyboard press detection should give me Ctrl and V). I already tried using TextBox.InputBegan, TextBox.InputChanged, and TextBox.InputEnded, but those don’t fire when I press my keyboard. UserInputService just doesn’t fire when I’m focusing on a TextBox. Is there a solution?

1 Like

UserInputService just doesn’t fire when I’m focusing on a TextBox

That’s actually not true. UserInputService does fire even if you are focusing on a TextBox. What developers do to prevent this is run the check:

if not UIS:GetFocusedTextBox() then -- UIS stands for UserInputService

end
1 Like

You can also use either:

TextBox.Focused:Connect(function()
    -- do code
end)
or
if (TextBox:IsFocused()) then
    -- do code
end
3 Likes

I forgot to mention that this is for a plugin (I’m using widgets), so this just doesn’t work, I even tested this myself.

You can just get the text from the textbox whenever the person stops typing the the textbox.