Detect when player is typing or pressing?

I have a minimap and its really annoying when your typing in chat “M” because it brings up the minimap? how would I be able to detect if there typing in chat or actually inputting

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.M then

there have already been multiple posts about this on the developer forums

you would rewrite your code like this:

UserInputService.InputBegan:Connect(function(input,chat)
	if not chat then
		if input.KeyCode == Enum.KeyCode.M then
			-- your stuff here
		end
	end

InputBegan event fires 2 parameters which are input and chatting, input is the normal input, chatting is a boolean that fires if the player is chatting or no (to fix it, you can detect if the player not chatting if the chat boolean is true then the player is chatting, else then do the code normally)