UserInputService fires when typing

I have parts in my game that you can press F to toggle when your mouse is over it. However, if your mouse is over it, and you start typing, if you press “F” it will toggle. How do I disable this?

UserInputService.InputBegan passes two arguments to the callback: InputObject and a boolean to determine if the input is being used by a game process, such as the chat bar or the core menu.

UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if input.UserInputType == Enum.UserInputType.Keyboard then
        if input.KeyCode == Enum.KeyCode.F then
            -- ...
1 Like